Devil's advocacy continues below.

Felix Meschberger wrote:
Your statement seems to show that the ordering information is
intentionally and willfully discarded in the JSON render, because the
render is not implemented in an orderable way.  Is that the intention or
is the JSON render duck-ordering just as much as the JS guys?

Wrong. The JSON render renders the child nodes in exactly the order as
returned from the repository. The properties of nodes (or resources) are
of course not returned in any defined order simply because the JCR spec
does not define an order amongst the properties ...

So the JSON render is "duck-ordering" the properties of the objects it creates (they don't have to be JSONObject class to be unordered JSON objects, they just have to be anonymous objects in javascript notation).

In your other emails you're saying that this property order shouldn't be relied on. I'm honestly confused about the intention with regards to ordering in the JSON render.

Carsten's original email says:

"Currently the json output always renders an object representation of the requested resource.

Example:
a / b with props A and B
a / c with props C and D

doing a /a.-1.json results in:
{
  "b" : { A : ... },
  "c" : { C : ... }
}"

The output generated does not seem to have any explicit order when it comes to 
child nodes.  When viewed according to the spec and not the colloquial usage, 
the ordering has been disregarded when the data is transformed from a JCR node 
and property structure into a javascript object.

I personally don't care whether everything relies on the "duck-ordering" (get 
all your ducks in a row!).  The ordering itself is not even what Carsten is asking about. 
 He's trying to eliminate the duck-ordering and implement explicit ordering and he's run 
into the problem that ordered objects in JSON cannot have names and is suggesting that an 
object be allowed to bring that data inside of itself.

He wants to know how to allow for that given that there are possible conflicts 
with other properties which have been declared on the object.  I'm suggesting a 
specific namespace for derived/meta properties of this kind.  I'm also 
suggesting other ways to wrap the JSON objects to bring the ordering data in 
without using an explicitly ordered object construct, trying to find out what 
the community thinks is the best approach.

Regards,
J5

Reply via email to