allow comments in json

This commit is contained in:
AykutSarac 2023-05-22 18:24:00 +03:00
parent 40aeda5bf3
commit e19cdc70f8
No known key found for this signature in database
2 changed files with 3 additions and 1 deletions

View File

@ -40,6 +40,7 @@ export const MonacoEditor = () => {
if (monaco) {
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
validate: true,
allowComments: true,
...(jsonSchema && {
schemas: [
{

View File

@ -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<FileStates & JsonActions>()((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 }),