This:
{
4: "a"
}
is not legal JSON, keys in an object must be strings.
On the other hand:
{
"a": "b",
"a": "c"
}
_is_ valid JSON. What the JSON spec does NOT say is what value should
be taken into account. Some JSON parser implementations will take the
first, or the last, or any other in between -- I even recall one JSON
parser aggregating such values in an array (["a", "b"])!
Basically, it means you can NOT rely on the JSON parser behaving in
one particular way.
--
Francis Galiegue, fgal...@gmail.com
"It seems obvious [...] that at least some 'business intelligence'
tools invest so much intelligence on the business side that they have
nothing left for generating SQL queries" (Stéphane Faroult, in "The
Art of SQL", ISBN 0-596-00894-5)
Yep, that'd be nice to have... The problem is how to specify it.
Maybe using JSON Pointer, we could do something: complement
uniqueItems and add uniqueProperties for objects.
Let's take uniqueItems as an example. We could specify:
* uniqueItems: false (the current default);
* uniqueItems: # (equivalent of uniqueItems: true);
* uniqueItems: #/some/path
So, for instance, if you have items like:
{
"email": "so...@value.here"
}
in an array and want email to be unique, you could write:
{
"type": "array",
"items": {
"type": "object",
//etc
},
"uniqueItems": "#/email"
}
The rule would also be that if a JSON Pointer is dangling for a value
(item in an array, or values in an object), the instance is considered
invalid.
Comments?
--
Francis Galiegue, fgal...@gmail.com