3 ms·
The format for the keys is the same as a javascript object. They are unique strings or numbers. It's already in the Ecmascript standard for objects.
by simlevesque 10y ago
The format for the keys is the same as a javascript object. They are unique strings or numbers. It's already in the Ecmascript standard for objects.
- tlrobinson 10y agoThat doesn't mean it's as easy to parse as plain JSON or JSON Lines. In JS, non-streaming: JSON.parse(blob) Or blob.split("\n").map(line => JSON.parse(line)) respectively.
- dalke 10y agoCould you help me understand your response? I find it hard to match your statement to the JSON spec(s). Neither RFC 7159 nor ECMA 404 use the term "key". The standard for objects requires a string for the 'name' of an object member, which is certainly what you refer to. However, JSON does not allow a number. I tried looking at the ECMAScript spec. In http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf http://www.ecma-international.org/publications/files/ECMA-ST... : > An Object is logically a collection of properties. ... Properties are identified using key values . A property key value is either an ECMAScript String value or a Symbol value . That 'Symbol' has nothing to do with numbers, so only strings make sense for an external representation. Perhaps you mean to include the integer from the Array object? The spec says "An Array object is an exotic object that gives special treatment to array index property key ... A String property name P is an array index if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32-1." Is that limited range of integers what you mean when you saying that numbers are allowed as keys? Regarding uniqueness, the CSJ spec says nothing about uniqueness, so how do you know the keys must be unique? It doesn't inherit that from JSON. RFC 7159 says that in an object "The names within an object SHOULD be unique."; uniqueness is not required. It then adds "When the names within an object are not unique, the behavior of software that receives such an object is unpredictable." Therefore, I don't see how you drew the conclusion you did.