On Mon, Jun 18, 2012 at 1:09 PM, <
luismari...@gmail.com> wrote:
> hi, reading the latest draft from the RFC I'm implementing the enum check
> for the array type, I want to know if the enum will be used to check
> if the whole array matches one item from enum or if the enum field will be
> used to check individual items of the array
>
> to be clear, enum should be an array of arrays that defines all the arrays
> that can be defined as valid values for that field (with comparison as of
> section 5.17) or should it be an array of items that defines which array
> items are valid?
>
It will check equality of the array to the value in the enum. A JSON
array is a JSON value like any other, after all.
Two array JSON instances are equal if and only if:
* they both have the same number of items, and
* an item at index n in the first instance equals the item at index n
in the second.
And this definition is, of course, recursive.
Similarly, equality for object instances is defined as follows:
* both object instances have the same set of keys, and
* for key k, the value of this key in the first instance equals the
value of this same key in the second instance.
Finally, it should be noted for completeness that the _order_ of keys
in a JSON object instance does _not_ matter:
{
"a": "b",
"c": "d"
}
is equals to
{
"c": "d",
"a": "b"
}
--
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)