JSON Sample Generator JSON Sample Generator

Home > Products > Liquid Studio > Sample Data From JSON Schema

The JSON Sample Generator creates a JSON document from a JSON Schema.

  • Simple intuitive wizard
  • Configurable output
  • Generate samples directly from and JSON Schema
  • Sample JSON from JSON Standards Library

The JSON generator takes the definitions within a JSON Schema (XSD) and creates the properties, objects, arrays and values required to make a valid JSON instance document. Primitive data values are generated that conform to the rules in the schema (length, min, max etc).

JSON Generator Typical Uses

Prototyping

While designing a JSON Schema it is often useful to be able to see what the resulting JSON document will look like. The JSON Schema diagrams make it clear what the structure is, but it is sometimes easier to see an example of an actual document in order to get a clear picture. The JSON Sample generator takes a JSON Schema and generates random sample JSON documents based on your schema. This allows you to quickly see any unexpected artefacts in the JSON document.

Development

When tasked with reading a JSON document into an application, it is useful to have a good set of valid test cases to work from. In the early stages of a development project such examples can be thin on the ground, so being able to generate them can save hours of manual typing. Furthermore when writing JSON from an application, it is useful to have a clear idea of what the JSON should look like, samples make it much easier to see where the applications output differ from the test cases.

Testing

Testing an application is all about having good test cases, and good test cases need good test data. Being able to generate sample JSON documents can save huge amounts of time when creating your test data, as it provides the skeletal message, making it easy for meaningful test values to be inserted into the document.

Example of generating JSON from JSON Schema

The following JSON Schema will be used to generate a JSON Sample document.

Bookstore XSD Example
{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "title": "My schema",
    "additionalProperties": false,
    "properties": {
        "Book": {
            "type": "array",
            "additionalItems": false,
            "items": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                    "Title": {
                        "type": "string"
                    },
                    "Price": {
                        "type": "number"
                    },
                    "ISBN": {
                        "type": "string"
                    },
                    "Genre": {
                        "type": "string"
                    },
                    "Author": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                                "FirstName": {
                                    "type": "string"
                                },
                                "Surname": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

This following JSON document was generated by the JSON Sample Generator from the Bookstore.json (above). The generator created default values based on the rules defined in the JSON Schema in order to create a JSON document that conforms to the source JSON Schema.

{
    "Book": [
        {
            "Title": "ABCDEFGHIJKLMNOPQRSTUVWX",
            "Price": 997.5,
            "ISBN": "ABCDEFGHIJKLMNOPQRSTUVWX",
            "Genre": "ABCD",
            "Author": [
                {
                    "FirstName": "ABCDEFGHIJKLM",
                    "Surname": "ABCDEFGHIJKLMNOPQRS"
                }, 
                {
                    "FirstName": "ABCD",
                    "Surname": "ABCDEFGHI"
                }, 
                {
                    "FirstName": "ABCDEFGHIJKLMNOPQRSTUVWXYZAB",
                    "Surname": "ABCDEFGHIJKLMNOPQRSTUVWXYZAB"
                }, 
                {
                    "FirstName": "ABCDEFGHIJ",
                    "Surname": "ABCDEFGHIJKLMNOPQRSTUVW"
                }
            ]
        }, 
        {
            "Title": "ABCDEFGHIJKLMNO",
            "Price": 115.25,
            "ISBN": "ABCDEFGHIJKLMNOPQRSTU",
            "Genre": "ABCDEFGHIJKLMNOPQRSTUV",
            "Author": [
                {
                    "FirstName": "ABCDEFGH",
                    "Surname": "ABCDEFGH"
                }
            ]
        }
    ]
}

Simplifies Development & Reduces Bugs Free Trial

More Editors and Tools

FEATURE DETAILS JSON Editor

JSON Editor

FEATURE DETAILS Graphical JSON Schema Editor

Graphical JSON Schema Editor

FEATURE DETAILS Infer JSON Schema

Infer JSON Schema

FEATURE DETAILS JSON Schema Documentation Generator

JSON Schema Documentation Generator