Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate fields in JSON #846

Closed
lexaknyazev opened this issue Feb 19, 2017 · 3 comments
Closed

Duplicate fields in JSON #846

lexaknyazev opened this issue Feb 19, 2017 · 3 comments

Comments

@lexaknyazev
Copy link
Member

As pointed out by @andreasplesch in #845:

Also, I did not find a statement regarding duplicate keys in the json: last one wins ?

tl;dr: 1.0 spec is silent on this. For glTF 2.0, duplicate keys aren't allowed.


According to ECMA-262 definition of JSON.parse (5.1, 6.0, 7.0):

In the case where there are duplicate name Strings within an object, lexically preceding values for the same key shall be overwritten.

But RFC 7159, Section 4 gives a bit different perspective:

The names within an object SHOULD be unique.
...
An object whose names are all unique is interoperable in the sense that all software implementations receiving that object will agree on the name-value mappings. When the names within an object are not unique, the behavior of software that receives such an object is unpredictable. Many implementations report the last name/value pair only. Other implementations report an error or fail to parse the object, and some implementations report all of the name/value pairs, including duplicates.

Because glTF 2.0 usage goes beyond Web, it would be reasonable to require uniqueness of names.

CC @pjcozzi

@andreasplesch
Copy link
Contributor

Thanks. As a side note, since it is not really possible to disallow people to attempt to use duplicate keys, it may be more accurate to say that this leads to undefined behaviour.

@pjcozzi
Copy link
Member

pjcozzi commented Feb 21, 2017

Because glTF 2.0 usage goes beyond Web, it would be reasonable to require uniqueness of names.

OK with me.

As a side note, since it is not really possible to disallow people to attempt to use duplicate keys, it may be more accurate to say that this leads to undefined behaviour.

The validator could detect this.

@pjcozzi
Copy link
Member

pjcozzi commented Jun 15, 2017

Updated in #826

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants