I have the following example JSON, for which I want to write a JSON Schema. The constraint is that property2 holds a list of string, which are dynamic, depending on the dataset. And in the property3 object some of the properties are named afters those strings.
{
"property1": "value",
"property2": ["value1","value2","value2"],
"property3": {
"title": "test",
"value1": "hello",
"value2": "world"
}
}
A JSON-Schema might look like this, but I don't know how to describe that the dynamic properties. Is that possible?
{
"title": "Test Object",
"type": "object",
"properties": {
"property1": {
"type": "string"
}
"property1": {
"type": "array"
}
"property3": {
"type": "object",
"properties": {
"title": {
"type": "string"
}
[ Something is missing here ]
}
}
}
}
You can not relate property values to property keys with Json-Schema (as of Draft v4).
You can:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.