Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate sample JSON from JSON schema [closed]

There are a number of tools available to generate JSON Schema from JSON but I can't find any to generate sample JSON from JSON Schema.

Any suggestions? Preferably something online that doesn't involve installing stuff.

like image 816
CodeClimber Avatar asked Oct 03 '14 14:10

CodeClimber


People also ask

How do you generate sample data from JSON Schema?

To generate sample JSON files from a JSON Schema, select Generate Sample JSON Files from the XML Tools > JSON Tools menu. The action opens a dialog box where you can configure a variety of options for generating the files.

How do you validate a JSON file against a schema?

The simplest way to check if JSON is valid is to load the JSON into a JObject or JArray and then use the IsValid(JToken, JsonSchema) method with the JSON Schema. To get validation error messages, use the IsValid(JToken, JsonSchema, IList<String> ) or Validate(JToken, JsonSchema, ValidationEventHandler) overloads.

What is $id in JSON Schema?

Declaring a unique identifier It is also best practice to include an $id property as a unique identifier for each schema. For now, just set it to a URL at a domain you control, for example: { "$id": "http://yourdomain.com/schemas/myschema.json" }

Is JSON Schema JSON?

JSON (JavaScript Object Notation) is a simple and lightweight text-based data format. JSON Schema is an IETF standard providing a format for what JSON data is required for a given application and how to interact with it.


2 Answers

I created an online tool called Mock Turtle. Using this tool you can:

  • build any JSON structure using a GUI interface
  • specify what data type you want for each JSON value, similar to Mockaroo (e.g. name, address, email, etc.)
  • generate a JSON document with random values based on your specified structure and data types
  • import JSON schema files to automatically create the GUI structure

enter image description here

Hope this helps anyone facing a similar problem :)

like image 128
Kazuto_Ute Avatar answered Oct 14 '22 15:10

Kazuto_Ute


There is a web based tool for generating JSON documents from JSON Schema documents at http://schematic-ipsum.herokuapp.com/ but I can't vouch for how well it works. It is included on the list of tools on the JSON Schema website.


The down vote is most likely because asking for tool recomendations is considered off-topic. If you phrased your question like "How can I do X? My requirements are Y", then you avoid such downvotes (hopefully).

like image 20
Relequestual Avatar answered Oct 14 '22 15:10

Relequestual