Reputation: 3856
I want to write a json-schema for the following json:
{
"peopleByID": {
"5534": {
"name": "Bob",
"weight": 82
},
"8423": {
"name": "Donna",
"weight": 73
},
...
}
}
The point is that I want to control the content of each property (required to contain name and weight), while not knowing in advance the property name (the person id). I couldn't find any solution for that.
Upvotes: 0
Views: 274
Reputation: 53996
additionalProperties
lets you set a schema that all properties (that weren't already covered by a properties
or patternProperties
keyword) must conform to:
"additionalProperties": {
"type": "object",
"required": ["name", "weight"]
}
Upvotes: 2