uniqueItems - sgpinkus/json-schema GitHub Wiki
THIS WIKI IS OBSOLETE. PLEASE SEE THE NEW JSON-SCHEMA-ORG/JSON-SCHEMA-SPEC REPOSITORY.
If the value of this keyword is boolean value false, validation of the instance always succeeds.
If the value of this keyword is boolean value true, then the array instance is valid if and only if all of its elements are unique. In other words, no two elements of the array instance should be equal to one another.
Two JSON values are considered equal if and only if:
- both are null; or
- both are of type boolean, number or string and have the same value; or
- both are arrays, and:
- have the same number of elements, and
- elements of both arrays, at the same position, are equal according to this definition; or
- both are objects, and:
- have the same set of members (keys), and
- member values of both objects, for the same member, are equal according to this definition.
Phew.
The value of the uniqueItems keyword MUST be a boolean.
Given this schema:
{
"uniqueItems": true
}
the following instances are valid:
- [];
- [ 1, 2 ];
- [ 1, "1" ];
and the following instances are invalid:
- [ 0, 1, 1 ];
- [ null, null ];
- [ { "a": "b", "c": "d"}, { "c": "d", "a": "b" } ] (the order of properties does not matter).