JSON Schema generator


#1

While there are a lot of tools for XML schemas, there aren’t many for JSON.

Are there any JSON Schema tools planned in the future? I can think of a few:

  • from a Java class
  • from a .NET class
  • from an RDBMS schema
  • from json examples

#2

It should work both ways around too right? Would it be good to at least be able to generate concrete Json examples from the schema? (I was not able to find such thing online).


#3

@fbongiovanni this sounds simple in theory, but it is extremely complex to do, that’s why you couldn’t find one already made on-line.

Of all the features in JSON Schema, the one that makes deriving an example from the hardest is regular expression validations. To be able to generate a string that matches a regEx, from the regEx itself, requires that you write a regEx engine yourself.

Most simple features can be easily implemented (character classes, negations, greediness, etc), but when you get to nevative-lookahead|behind, things get a bit harder.

This is a matter of investment/ROI, we can write something that emits valid examples that match 75% of regular expressions, whereas if the schema uses overly complex regexes, they fall out of the scope of the generator.


#4

Hi @damipoo,

You can use this online tool to generate JSON Schema from JSON examples:


#5

There are several online schema generator tools for doing that from a json input like : -
http://jsonschema.net/previous/
https://www.npmjs.com/package/json-schema-generator

These tools can automatically generate JSON schema from JSON string.

You can look into for more details : - http://stackoverflow.com/questions/7341537/tool-to-generate-json-schema-from-json-data