Ha, this is an old topic: http://markmail.org/message/l3shzw2wgrrabo53
Basically it is much nicer and simpler to encode child nodes as child objects instead of an entry in a child array. This way you can do json.child.grandchild in javascript to access known children by name, which is very common, and seems more common than needing an order. The real culprit IMHO is that javascript and the json spec neglected the order in the first place. JSON serialization is inherently ordered... If you do want the array notation, you can easily write a servlet/script that gives you that format (for a different selector, say ".array.json" or by overriding the default ".json" servlet). Cheers, Alex On 21.01.2014, at 10:35, Buzzterrier <[email protected]> wrote: > Ok, I figured out why I am getting random ordering. Sling is returning the > nodes in the correct order in the response (I should have checked that > -sorry). But when converting the response to a JSONObject, the child nodes, > which are also represented as JSONObjects are randomized. This is per the > JSON spec: > > An object is an unordered set of name/value pairs. > > So, why are you not returning the child nodes as a JSONArray? This would > preserve order and seems to be a far more intuitive structure. > > JSONOBject > JSONArray[] > JSONObject > JSONArrray[] > JSONObject > JSONArray[] > > > > > -- > View this message in context: > http://apache-sling.73963.n3.nabble.com/Getting-ordered-nodes-tp4030376p4030493.html > Sent from the Sling - Users mailing list archive at Nabble.com.
