Hi, Edelson, Justin schrieb: > Felix Meschberger wrote: >> The spec is actually very clear: The order amongst properties in objects >> is explicitly undefined. That is, code must never expect properties to >> have a specific order. > Right, but implementations may choose (as it appears most JavaScript browser > engines do) to implement an object in such a way as to retain order. In any > case, we're absolutely in agreement that dependence on this behavior is dead > wrong.
Yes, that's what I tried to say ;-) > > But are we also in agreement that the Sling JSON renderer is flawed in so far > as it doesn't support ordered child nodes and same name siblings? No, we are not ;-) Sling JSON Render keeps the order amongst child nodes and does not define any order amongst properties (simply because JCR does not have such ordering either). Regarding same-name-sibblings: Well, -- honestly and IMHO -- this is a flawed concept (and yes, I know why it is in the spec and I also know that its use is discouraged...). .. And same-name-sibblings is not supported by JavaScript objects, regardless of any ordering questions... > I don't see a good way to change this without breaking backwards > compatibility. What needs to be changed breaking backwards compatibility ? Regards Felix > > Justin > > > ________________________________ > > From: Felix Meschberger [mailto:[email protected]] > Sent: Wed 9/16/2009 2:02 PM > To: [email protected] > Subject: Re: Extending the json renderer > > > > Hi, > > Edelson, Justin schrieb: >> ... If a JSON implementation implements objects in a >> non-orderable way (which is permitted under the spec and >> done in the json.org Java implementation), you can never >> recover the original order of child nodes. > > The spec is actually very clear: The order amongst properties in objects > is explicitly undefined. That is, code must never expect properties to > have a specific order. > > The problem is that browser JavaScript interpreters are implemented > providing a property order, namely the order of property definition > (similar to the ordering of the LinkedHashMap in Java) and client-side > java scripters unfortunately tend to depend on this "feature". > > Regards > Felix > > >
