function parse
parse(text: string): JsonValueConverts a JSON with Comments (JSONC) string into an object.
Examples
Usage
Usage
import { parse } from "@std/jsonc"; import { assertEquals } from "@std/assert"; assertEquals(parse('{"foo": "bar"}'), { foo: "bar" }); assertEquals(parse('{"foo": "bar", }'), { foo: "bar" }); assertEquals(parse('{"foo": "bar", } /* comment *\/'), { foo: "bar" });
Parameters
text: stringA valid JSONC string.
Return Type
The parsed JsonValue from the JSONC string.
Throws
SyntaxErrorIf the JSONC string is invalid.