Is multiple "if" "then" valid in JSON schema? #503
Replies: 1 comment
-
You can't have multiple {
"if": {...},
"then": {...},
"if": {...},
"then": {...}
} In JSON Schema, you can combine schemas with the {
"allOf": [
{
"if": {...},
"then": {...}
},
{
"if": {...},
"then": {...}
}
]
} Putting each Another thing to look out for is to make sure you're putting the Finally, the "domainFields" schema doesn't look right. I think you're trying to do something more like this, {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"properties": { ... number domain field properties ... }
},
{
"type": "object",
"properties": { ... text domain field properties ... }
},
{
"type": "object",
"properties": { ... date domain field properties ... }
}
]
}
} |
Beta Was this translation helpful? Give feedback.
-
I'm trying to create a JSON schema where I have multiple subschema that should populate conditionally and each of them are unrelated
Example: Only populate "frequency" if "occurred" is true and only populate "domainFields" if "drillDown" is true
(Edit: Added code block for readability.)
Beta Was this translation helpful? Give feedback.
All reactions