Function parse

  • Converts a JSON with Comments (JSONC) string into an object.

    Parameters

    • text: string

      A valid JSONC string.

    Returns GlobOptions

    The parsed JsonValue from the JSONC string.

    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" });

    If the JSONC string is invalid.