function parse
parse(text: string,unnamed 1?: ParseOptions): JsonValueConverts a JSON with Comments (JSONC) string into an object.
If a syntax error is found, throw a SyntaxError.
Examples
Example 1
Example 1
import { parse } from "@std/jsonc"; console.log(parse('{"foo": "bar", } // comment')); // { foo: "bar" } console.log(parse('{"foo": "bar", } /* comment *\/')); // { foo: "bar" } console.log(parse('{"foo": "bar" } // comment', { allowTrailingComma: false, })); // { foo: "bar" }
Parameters
text: stringA valid JSONC string.
optional
unnamed 1: ParseOptionsReturn Type
JsonValue