3 ms·
> This is not in fact out of spec. The JSON spec does not define semantics [...] for what to do about ordering of objects. What? It is literally on the first p
by dtech 7y ago
> This is not in fact out of spec. The JSON spec does not define semantics [...] for what to do about ordering of objects.
What? It is literally on the first page of json.org and section 1 of RFC 7159 [1]
> An object is an unordered set of name/value pairs.
> An object is an unordered collection of zero or more name/value pairs
[1] https://tools.ietf.org/html/rfc7159#section-1 https://tools.ietf.org/html/rfc7159#section-1
- patrickthebold 7y agoThere are multiple standards. https://www.ecma-international.org/publications/standards/Ecma-404.htm https://www.ecma-international.org/publications/standards/Ec... Is more relaxed. >The JSON syntax does not impose any restrictions on the strings used as names, does not require that name strings be unique, and does not assign any significance to the ordering of name/value pairs. These are all semantic considerations that may be defined by JSON processors or in specifications defining specific uses of JSON for data interchange. Also it's pretty clear that the keys must have an order going over the wire. And JavaScript objects (which aren't unrelated to JSON have an order now) https://www.stefanjudis.com/today-i-learned/property-order-is-predictable-in-javascript-objects-since-es2015/ https://www.stefanjudis.com/today-i-learned/property-order-i...