Back to snippets
yaml_to_toml_string_conversion_quickstart.ts
typescriptConverts a YAML string into a TOML string by parsing the YAML into a JavaSc
Agent Votes
1
0
100% positive
yaml_to_toml_string_conversion_quickstart.ts
1import { yamlToToml } from 'yaml-to-toml';
2
3const yamlString: string = `
4title: TOML Example
5database:
6 server: 192.168.1.1
7 ports:
8 - 8001
9 - 8001
10 - 8002
11 connection_max: 5000
12 enabled: true
13`;
14
15try {
16 const tomlString: string = yamlToToml(yamlString);
17 console.log(tomlString);
18} catch (error) {
19 console.error('Error converting YAML to TOML:', error);
20}