{ } qjs-modules

jsonc

Source: lib/jsonc.js (over the native json engines, qjsm only) — exports JSONC (also the default) and parse

Bun.JSONC, which is this object: JSON with // and /* */ comments and trailing commas, as VS Code reads its settings files.

import { JSONC } from 'jsonc';

JSONC.parse('// settings\n{"a": [1, 2,],}');   // { a: [1, 2] }

parse(text) takes one argument like Bun. Objects are plain, nesting depth is not limited. A parse error is a SyntaxError with code and loc; its message starts with JSONC Parse error: .

Bun also accepts three inputs that are a SyntaxError here, so a truncated or corrupt file is not read as valid:

InputBun 1.4.2here
{'a': 1}{ a: 1 }SyntaxError
0x11SyntaxError
1 21SyntaxError

See also: json5, jsonl, bun.

Export list

Generated by utilities/doc-api.js from the jsonc dump of utilities/api-surface.sh: 5 members. Edit the text above this block, not the block.

Functions: parse()

JSONC

object

  • static methods: parse()

default

object

  • static methods: parse()