Function from_str

Source
pub fn from_str<'input>(
    source: &'input str,
) -> Result<JSONText<'input>, ParsingError>
Expand description

Turn a str input into the JSONText abstract JSON5 model

Not to be confused with crate::de::from_str. This typically is not used directly. Instead, most of the time when you want to work with AST, you probably want to use the functions provided in the crate::rt module instead.

use json_five::parser::{from_str, JSONText, JSONValue};

let res = from_str("{}").unwrap();
let expected = JSONText{value: JSONValue::JSONObject {key_value_pairs: vec![]}};
assert_eq!(res, expected)