diff --git a/jsonc/mod.ts b/jsonc/mod.ts index ca5fc80c02e0..883c57c1f018 100644 --- a/jsonc/mod.ts +++ b/jsonc/mod.ts @@ -6,6 +6,10 @@ * {@link https://code.visualstudio.com/docs/languages/json#_json-with-comments | JSONC} * (JSON with comments). * + * On top of what JSON allows, this module accepts line comments (`//`), block + * comments, and a trailing comma after the last member of an object or array. + * Comments are discarded when parsing. + * * Currently, this module only provides a means of parsing JSONC. JSONC * serialization is not yet supported. * diff --git a/jsonc/parse.ts b/jsonc/parse.ts index 608b65b1503c..81f6e24bfb49 100644 --- a/jsonc/parse.ts +++ b/jsonc/parse.ts @@ -7,6 +7,10 @@ export type { JsonValue }; /** * Converts a JSON with Comments (JSONC) string into an object. * + * On top of what JSON allows, line comments (`//`), block comments, and a + * trailing comma after the last member of an object or array are accepted. + * Comments are discarded. + * * @example Usage * ```ts * import { parse } from "@std/jsonc"; @@ -18,6 +22,7 @@ export type { JsonValue }; * ``` * * @throws {SyntaxError} If the JSONC string is invalid. + * @throws {TypeError} If called with `new`. * @param text A valid JSONC string. * @returns The parsed JsonValue from the JSONC string. */