Ask HN: Is anyone using json schema?
I am building a JSON editor/viewer that conforms to a schema. It is sort of like a non developer friendly way to edit or view documented JSON. The best resource i've found for any kind of existing JSON schema standard is at http://json-schema.org
Either I have not been paying attention or I have not seen many API's or other JSON related software using any kind of schema for reference or validation.
I'm curious as to the pulse of who's adopted or found using a JSON schema useful or if it has been largely ignored and we're doing just fine without it.
17 comments
[ 4.8 ms ] story [ 48.4 ms ] thread> largely ignored and we're doing just fine without it
is a pretty good description of how it's going here. Let be be a bit more specific. We used to build lots of SOAP services, and maintaining the schemas that clearly specified the interface was a real effort. When we moved to APIs that used JSON, at first we did little in the way of documentation - and as usual, doing no documentation worked fine at first.
After the JSON API use grew to on the order of 300 developers in teams across the country "no documentation" didn't scale so well. Instead, we've been using swagger specifications to document our APIs. First of all, the swagger specification is far less detailed and precise than the XML schema were. Secondly, my observation (not carefully measured) is that only about 80-90% of the swagger specifications are even accurate. And no one cares. Apparently the level that works for us is just slightly above "no documentation" but well below "clear and accurate specifications".
And I'm (mostly) OK with that.
I suppose the use case is somewhat similar to XSD, but this is more intuitive and way less verbose. There's also immediate value in using it to parameterize resource types to stay DRY when you use the same resource across multiple endpoints.
I think of it more for templating than validation.
http://raml.org/developers/raml-200-tutorial#extract-schemas
- It's ugly and borderline impossible to write by hand because it's JSON. To document something complex your JSON objects get 20 layers deep and you don't get any decent commenting.
- Because it's so hard to read, it's useless by itself as a guide to how the JSON should be structured.
- Someone would change the code and always forget to update the schema to match. It only makes sense if you're somehow generating the code from the schema.
We used http://www.jsonschema2pojo.org/ (via the gradle plugin) on a previous project. I think it worked fairly well.
If you are looking for a good JSON editor that respects JSON schema to compare with your implementation, try Visual Studio Code [2].
[1] http://vega.github.io/
[2] https://code.visualstudio.com/download
It's just the equivalent of an XSD. A lot of people use XML without an XSD. I think it's perfectly fine to not use JSON schema if you don't want to, but having it gives you an easy path toward validating user-generated JSON. It's a nice-to-have.
https://pypi.python.org/pypi/jsonmerge
Blog post with some background:
https://www.tablix.org/~avian/blog/archives/2014/08/jsonmerg...
It's not a fantastic UX but it works and it's fast to develop.
The docs are sparse but for my money the format is relatively intuitive. I'd prefer to be using XML/XSL/XSLT as they are FAR more powerful, but that's just what you get with JSON.
It was also great for contract testing in CI of other teams' services (warning us if they slipped some breaking change into the build).