2 ms·
He links to a stack overflow question and I think this answer is pretty good https://stackoverflow.com/a/23195243/497116 https://stackoverflow.com/a/23195243/49
by Zalastax 9y ago
He links to a stack overflow question and I think this answer is pretty good https://stackoverflow.com/a/23195243/497116 https://stackoverflow.com/a/23195243/497116.
https://www.ietf.org/rfc/rfc4627.txt https://www.ietf.org/rfc/rfc4627.txt says "The names within an object SHOULD be unique". https://tools.ietf.org/html/rfc7159 https://tools.ietf.org/html/rfc7159 is more lax and instead says "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".
It's unfortunate that the correct behavior is not agreed on and today we saw the consequences of that.
- sratner 9y agoFrom https://www.ecma-international.org/ecma-262/5.1/#sec-15.12 https://www.ecma-international.org/ecma-262/5.1/#sec-15.12 -- "NOTE: In the case where there are duplicate name Strings within an object, lexically preceding values for the same key shall be overwritten."
- Zalastax 9y agoYes, a good point! For interoperability it would be best if everyone followed the ECMA standard for JSON from 2011. It seems like they forgot to even mention duplicate keys in ECMA-404 from 2013 which seems very strange. RFC7159 uses the word SHOULD but I don't think the JSON parser Jiffy has actually understood the full implications and carefully weighed before choosing to allow duplicate elements.