4 ms·
Does https://json-schema.org/ https://json-schema.org/ not work for you?
by halfdan 7y ago
Does https://json-schema.org/ https://json-schema.org/ not work for you?
- sacado2 7y agoI 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"?
- itafroma 7y agoYes: { "$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" } } }
- ChrisMarshallNY 7y agoIt would, if anyone used it. The thing about XML Schema, is that it is completely "baked into" pretty much every tool and library out there, so you can do "on-the-fly" runtime validation. JSON is really about minimizing text. It works really well for this. Another issue, is that JSON doesn't have comments, so it can be difficult to annotate a JSON file.