I want to know whether there is a method in which I can generate sample json output based on a json schema input. For example of the following input:
{
"title": "Example Schema",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"description": "Age in years",
"type": "integer",
"minimum": 0
}
},
"required": ["firstName", "lastName"]
}
Output:
{
"firstName": "RandomFirstName",
"lastName": "RandomLastName"
}
I have a large json schema with plenty of validations, so to generate a sample valid json, I could either create one manually using either Java or just a type it into a file. Is there a better way available?
You can try the JSON Schema Faker. It will take a schema and generate/output a JSON object that will validate against the schema.