Reputation: 47
Can i create json schema for validitaion this object without redesigning json in other form?
{
"itemColors": {
"40": "#12ffd6",
"69": "#f90861",
"185": "#063ac3"
},
"itemVisible": {
"32": true,
"33": true,
"34": true,
"36": true,
"37": true,
"38": true,
"39": true,
"40": true,
"41": true,
"55": true,
"56": true,
"69": true,
"185": true,
"187": true,
"196": true,
"197": true,
"198": true
}
}
Objects can have different numbers of properties.
Values for ItemColors:
Same thing for itemVisible but values must be of type boolean
Upvotes: 1
Views: 296
Reputation: 3141
You can specify the schema of unspecified properties using "additionalProperties"
:
{
"properties" : {
"itemColors" : {
"type" : "object",
"additionalProperties" : {
"type" : "string"
}
},
"itemsVisible" : {
"type" : "object",
"additionalProperties" : {
"type" : "boolean"
}
}
}
}
Read more here: https://spacetelescope.github.io/understanding-json-schema/reference/object.html
Upvotes: 1