MCPcopy Create free account
hub / github.com/dmno-dev/bumpy / parseJsonc

Function parseJsonc

packages/bumpy/src/utils/jsonc.ts:5–11  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

3const stringOrTrailingCommaRe = /("(?:\\?[^])*?")|(,\s*)(?=]|})/g;
4
5export function parseJsonc(text: string): unknown {
6 try {
7 return JSON.parse(text);
8 } catch {
9 return JSON.parse(text.replace(stringOrCommentRe, '$1').replace(stringOrTrailingCommaRe, '$1'));
10 }
11}

Callers 2

jsonc.test.tsFile · 0.90
readJsoncFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…