Skip to content

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

allow comments in json

AykutSarace19cdc70f809
diff --git a/src/components/MonacoEditor/index.tsx b/src/components/MonacoEditor/index.tsx
index 48187a38..c67f4185 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 49f2bbeb..011df07d 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<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 }),