Function jsonc_parser::parse_to_ast

source ·
pub fn parse_to_ast<'a>(
    text: &'a str,
    collect_options: &CollectOptions,
    parse_options: &ParseOptions
) -> Result<ParseResult<'a>, ParseError>
Expand description

Parses a string containing JSONC to an AST with comments and tokens.

Example

use jsonc_parser::CollectOptions;
use jsonc_parser::parse_to_ast;
use jsonc_parser::ParseOptions;

let parse_result = parse_to_ast(r#"{ "test": 5 } // test"#, &CollectOptions {
    comments: true, // include comments in result
    tokens: true, // include tokens in result
}, &Default::default()).expect("Should parse.");
// ...inspect parse_result for value, tokens, and comments here...