Skip to main content

toml_to_json

Function toml_to_json 

Source
pub fn toml_to_json(toml: &str) -> Result<String, Box<dyn Error>>
Expand description

Converts a TOML document to a JSON value.

TOML datetimes are stringified (2024-01-15T10:30:00Z becomes the string "2024-01-15T10:30:00Z"), matching the behavior of YAML. Nested tables and arrays of tables map directly to JSON objects and arrays.

§Errors

Returns an error if the TOML is malformed.

§Examples

use sheeter_engine::toml_to_json;
let json = toml_to_json("a = 1\n").unwrap();
assert_eq!(json, r#"{"a":1}"#);