4 ms·
What if you need to encode arbitrary dictionaries, which may have keys like "//", rather than objects with specific named attributes? And what if you want mult
by dlubarov 15y ago
What if you need to encode arbitrary dictionaries, which may have keys like "//", rather than objects with specific named attributes?
And what if you want multiple comments in the same scope (say, a comment before each attribute)? From the RFC: "The names within an object SHOULD be unique." In practice parsers will just override values, as JS does, but I think it would be legal to reject JSON with duplicate keys.
- polemic 15y agoIMHO, the complexity that this would introduce just highlights why it's a good idea not to have them. > "but I think it would be legal to reject JSON with duplicate keys." No it would not. `SHOULD` has a very specific meaning: SHOULD This word, or the adjective "RECOMMENDED", mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course. See http://www.ietf.org/rfc/rfc2119.txt http://www.ietf.org/rfc/rfc2119.txt An object with duplicate keys must be parsed, but the exactly result will be implementation specific (undefined).