Json validation with json-schema

Hi all,
Do you know if there is a way to make codemirror validate (and provide suggestions - autocomplete) a json document using a json-schema?

Thanks a lot

You can program this, but I’m not aware of an existing ready-to-use solution that does it.

Thank you,
I’m not sure I can get the time to code it, but in case I do; can you point me to the right direction? I’ve never read the codemirror source before.

You probably don’t need to read the source—just the docs. You can implement features like this as addons without modifying the core library. You’d probably want to integrate with the lint addon for the checking and the show-hint addon for providing completions.

my json validator is worked but i want json key name is allowed key name.not allowed key name is detected when error will throwed

Hi @jacarma @solai

I am also trying to validate the JSON-LD Schema with my JSON-LD document and display the errors in the CodeMirror. Do you have a sample code that you tried? Any sample code guiding me to the answer would be really appreciated.

We have just published a package that gives a starting point for json4 and json5, building off of existing grammars, let us know what you think! many improvements yet to come. we hope to make formatting more extensible

and the demo:

https://codemirror-json-schema.netlify.app/

many solutions we found in the wild used json-source-map, but we found the codemirror AST was all we needed.

It is INSANE to me that I googled this today (for the first time) and you JUST published this.

Serendipity at its finest.

1 Like

Very cool. I’ve listed it in the community extension list.

1 Like