We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 153e527 commit 6df52feCopy full SHA for 6df52fe
src/jsonc/jsonc.ts
@@ -0,0 +1,7 @@
1
+export const JSONC = {
2
+ parse: (text : string, reviver?: (this: unknown, key: string, value: unknown) => unknown) => {
3
+ text = text.replace(/((")(?:\\[\s\S]|.)*?\2|\/(?![*\/])(?:\\.|\[(?:\\.|.)\]|.)*?\/)|\/\/.*?$|\/\*[\s\S]*?\*\//gm, '$1');
4
+ return JSON.parse(text, reviver);
5
+ },
6
+ stringify: JSON.stringify
7
+}
0 commit comments