diff --git a/src/components/MonacoEditor/index.tsx b/src/components/MonacoEditor/index.tsx index 48187a3..c67f418 100644 --- a/src/components/MonacoEditor/index.tsx +++ b/src/components/MonacoEditor/index.tsx @@ -40,6 +40,7 @@ export const MonacoEditor = () => { if (monaco) { monaco.languages.json.jsonDefaults.setDiagnosticsOptions({ validate: true, + allowComments: true, ...(jsonSchema && { schemas: [ { diff --git a/src/store/useFile.ts b/src/store/useFile.ts index 49f2bbe..011df07 100644 --- a/src/store/useFile.ts +++ b/src/store/useFile.ts @@ -1,3 +1,4 @@ +import { parse } from "jsonc-parser"; import debounce from "lodash.debounce"; import _get from "lodash.get"; import _set from "lodash.set"; @@ -90,7 +91,7 @@ const useFile = create()((set, get) => ({ getHasChanges: () => get().hasChanges, setContents: ({ contents, hasChanges = true }) => { set({ ...(contents && { contents }), hasChanges }); - debouncedUpdateJson(JSON.parse(contents as string)); + debouncedUpdateJson(parse(contents as string)); }, setError: error => set({ error }), setHasChanges: hasChanges => set({ hasChanges }),