Otherwise, I try to use JSON, where possible, because I am not a masochist.
Otherwise, I try to use JSON, where possible, because I am not a masochist.
I LOATHE XML Schema. I have used it for years, and have never memorized it. I still need to look it up like a n00b, every time I use it.
But the simple fact of the matter is, is that so many people and projects have inculcated it into hundreds (if not thousands) of toolsets and specs (Like -Ick- WSDL), that it really is the only viable game.
People tend to like JSON precisely because it eschews the kind of overhead that is the definition of XML Schema.
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.
{
"$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"
}
}
}