Hi,
(renaming the thread to attract attention of our JSON folks)
On Jan 22, 2008 9:47 AM, Peter Svensson <[EMAIL PROTECTED]> wrote:
> ...The json that would be nice to have is something like this;
>
> {
> label: 'name',
> identifier: 'name',
> items:
> [
> { name:'Fruit', type:'category'},
> { name:'Cinammon', type: 'category',
> children:
> [
> { name:'Cinammon Roll', type:'poptart' },
> { name:'Brown Sugar Cinnamon', type:'poptart' },
> { name:'French Toast', type:'poptart' }
> ]
> },
> { name:'Chocolate', type: 'category'}
> ]
> }
>
> Where the only important stuff here is that child nodes should be put in a
> separate array [], not as an object to the parent node, like this;
...(snipped current format)
Ok, so basically you'd like the child nodes to be in an array named "children".
I know others on this list have more javascript experience than me,
what do people think?
> ....Also, I have difficulties understanding what to do with the
>
> "testing":
> {"jcr:primaryType":"nt:unstructured",
>
> part, since I would somehow like it to be like this;
>
> children:
> [
> {
> title: 'testing',
> jcr_primaryType: 'nt:unstructured',
> children:
> [
> { title:"test2", sling_resourceType:
> "usling/example", jcr_primaryType: "nt:unstructured", text: "Default text of
> the test node"},
> ....
> ]
> }
> ]
>
> Hmm. I really think that this would be the correct translation, now that
> I've printed it out. The problem was in choosing how to remove the current
> "name: {}" structure to move the name into the object (where it is anyway),
> like children: [{title: name....}]...
Ok, I agree that the above is more immediately understandable than the
current format.
The downside, iiuc, is that if forces the use of ".children." to
access children...well, not sure if that's a downside, let's hear what
other javascript aficionados think!
> ...Note that children is just a convenient name, and doesn't mean anything
> magic. Also, I would feel very much more comfortable not having quotes
> around property names. I understand that they're there to escape the ':' ,
> which are very magic in js and separates property names from values,
> therefore I replaced them with underscores....
IIUC, the goal with removing the quotes is only to make the JSON look
nicer, is that right?
The problem with transforming sling:resourceType to sling_resourceType
in JSON is the possible confusion in documentation and in people's
minds...I don't like that too much.
As you indicate, making other JSON renditions pluggable would be easy,
but I think we should be able to agree on a good enough default
format.
-Bertrand