I have a JSON object where one of the fields contains a JSON string. I need to write a JSON schema that validates this JSON string field. Here’s an example of the JSON object I’m working with:
<code>{
"id": 1,
"name": "John Doe",
"details": "{"age": 30, "email": "[email protected]"}"
}
</code>
<code>{
"id": 1,
"name": "John Doe",
"details": "{"age": 30, "email": "[email protected]"}"
}
</code>
{
"id": 1,
"name": "John Doe",
"details": "{"age": 30, "email": "[email protected]"}"
}
“details” is a string which has a json object. I want to validate details to have a specific structure.
JSON schema that i have so far :
<code>"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"details": {
"type": "string",
<Schema to add validation>
</code>
<code>"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"details": {
"type": "string",
<Schema to add validation>
</code>
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"details": {
"type": "string",
<Schema to add validation>
How do i approach this to be handled in json schema itself?
Any help would be greatly appreciated. Thank you!
New contributor
Sai Prasanna S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.