Check syntax / well-formed only.

72 views
Skip to first unread message

Edward Cullen

unread,
Dec 2, 2013, 4:10:54 PM12/2/13
to jsons...@googlegroups.com
Can jsonschema be used to check only for well-formedness?

I'm joining a project that I know is going to be JSON-heavy and validation has come up, primarily as a debugging aid. Right now, we don't know what the data will look like, but we do want to ensure that we're starting with valid JSON; being able to use jsonschema will give us a nice leg-up if/when we need full schema validation (which is more likely than not!).

Also, if this is possible, and someone has already done performance comparisons between json.load() or json.loads() and jsonschema.validate(<well-formed only>), that would be really useful too :)

TIA

Julian Berman

unread,
Dec 2, 2013, 4:28:10 PM12/2/13
to jsons...@googlegroups.com
Hey!

By the time jsonschema sees your instance and schema, it needs to have already been loaded (by a JSON parser) into Python objects, so no, there's no way inside jsonschema to check that.

There are plenty of benchmarks out there for which the fastest JSON parser is for some sample data, if simplejson isn't fast enough for you (json.load and json.loads are going to be comparable, since simplejson is kind of dumb and just implements load as json.loads(file.read())).

Cheers,

Julian

Edward Cullen

unread,
Dec 3, 2013, 8:06:38 AM12/3/13
to jsons...@googlegroups.com
Cool, thanks for such a detailed response!
Reply all
Reply to author
Forward
0 new messages