Re:When XML Beats JSON: UI Layouts
by sacado2 on Wednesday October 30, 2019 @09:02AM
(#21397211)
I don't know JSON schema really well; Can you say you want a `price` value to be a non-negative decimal value with at most two digits after the comma, and you want the `currency` value be exactly one of the following : "EUR", "USD", "GBP", the default if not specified being "EUR"?
[ Parent
| on HN ]
Yes:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"price": {
"type": "number",
"multipleOf": 0.01,
"minimum": 0
},
"currency": {
"type": "string",
"enum": ["EUR", "USD", "GBP"],
"default": "EUR"
}
}
}