Hello, I am currently working on creating a JSON instance from a given JSON schema.
I would greatly appreciate a Typescript solution, but I am open to any other suggestions as well.
Below is a sample of the schema file: sample-schema.json. My goal is to develop a function that can convert such schema into a schema instance.
For example, in the sample-schema.json file:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
},
"address": {
"type": "object",
"properties": {
"street_1": {
"type": "string"
},
"street_2": {
"type": "string"
},
"city": {
"type": "string"
},
"state": {
"type": "string",
"enum": [
"AL",
"AK",
"AS"
]
},
"zip_code": {
"type": "string"
}
}
},
"birthday": {
"type": "string"
},
"notes": {
"type": "string"
}
},
"required": [
"last_name"
]
}
The desired output should be as follows:
{
"first_name": "",
"last_name": "",
"last_name": "",
"address": {
"street_1": "",
"street_2": "",
"city": "",
"state": "",
"zip_code": ""
},
"birthday": "",
"notes": ""
}
When calling the function with the provided schema, it should generate the corresponding JSON instance. Despite my efforts to find a solution through Google, all results pertained to converting JSON to JSON schema.