Yes, actually, I personally prefer to just have object within objects. it's
just that I have to translate the thing to a format that Dojo's Tree widget
can consume. So in that respect it makes more sense to translate it locally,
instead of changing the output from the server. Maybe to be able to have two
different json formats, one which was dojo pluggable?

Another thing that I've noticed is that when I pasted a workable dojo editor
(which is in this comment somewhere) html page into Sling, (it worked very
well), when I get the generated json, the quotes inside the page is not
escaped, which leads to a really illegal json structure, which looks a bit
like thsi;


{
  ...
       "d1":
                   { "title":"d1","sling:resourceType":"<!DOCTYPE HTML
PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\r\n            \"
http://www.w3.org/TR/html4/strict.dtd\";>\r\n<html>\r\n<head>\r\n<meta
http-equiv=\"Content-Type\" content=\"text/html;
charset=UTF-8\">\r\n<title>Editor Demo<\/title>\r\n   .......
  ...
}

Note that the property value of the "sling:resoruceType" is double quoted
"", but inside those quotes, there are string like 'content="text/html"',
et.c. So maybe it would be a good idea to have an escaping strategy for
content inside the json structure. This can be non-trivial, since the
content can contain client-side js which uses escaping itself, and so on.

The most 'safe' approach would be to urlencode all properties which contain
this kind of information (i.e. can be showed in the browser), since it is
trivial to revert it back, and it is supposed to be consumed by javascript
anyway.  What do people think?

Cheers,
PS

Cheers,
PS

On Jan 22, 2008 10:21 AM, Philipp Koch <[EMAIL PROTECTED]> wrote:

> hi,
> i like the current "json node export" format since it seems to me more
> natural (in respect to jcr).
>
> regards,
> philipp
>
> On 1/22/08, Peter Svensson <[EMAIL PROTECTED]> wrote:
> > On Jan 22, 2008 10:08 AM, Bertrand Delacretaz <[EMAIL PROTECTED]>
> > wrote:
> >
> > > Hi,
> > >
> > > (renaming the thread to attract attention of our JSON folks)
> > >
> >
> > Good idea. Thanks.
> >
> >
> > >
> > > 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!
> > >
> >
> > Well, I think its OK. Children would refer to an array of object, and
> each
> > object could have another children property which had an array as value,
> so
> > I don't think it would be a problem (from a purely js perspective)
> >
> >
> > >
> > > > ...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?
> > >
> >
> > Argh! You got me there :). I'm just used to not having any quotes on
> > property names, but I'd have to google to know if there's any
> difference, so
> > for now, yes only to look nice - and I agree that it's not a good thing
> to
> > have the name change, depending on platform.
> >
> >
> > >
> > > 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
> > >
> >
>

Reply via email to