Hi Bertrand,

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;

{
    "jcr:primaryType":"nt:unstructured",
    "testing":
           {"jcr:primaryType":"nt:unstructured",
        "test2":
                   {
"title":"test2","sling:resourceType":"usling/example","jcr:primaryType":"nt:unstructured","text":"Default
text of the test node"},
        "dojo_editor":
                   { "title":"dojo
editor","sling:resourceType":"usling/editor","jcr:primaryType":"nt:unstructured","text":"This
is the dojo 1.x editor" },
               "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    <style
type=\"text/css\">\r\n        @import \"
http://o.aolcdn.com/dojo/1.0.0/dijit/themes/tundra/tundra.css\";\r\n
@import \" http://o.aolcdn.com/dojo/1.0.0/dojo/resources/dojo.css\"\r\n
<\/style>\r\n    <script type=\"text/javascript\" src=\"
http://o.aolcdn.com/dojo/1.0.0/dojo/dojo.xd.js\ "\r\n
djConfig=\"parseOnLoad: true\"><\/script>\r\n        <script
type=\"text/javascript\">\r\n       dojo.require(\"dojo.parser\");\r\n
dojo.require(\" dijit.Editor\");\r\n     <\/script>\r\n<\/head>\r\n<body
class=\"tundra\">\r\n<form method=\"post\">\r\n<textarea name=\"field\"
width=\"200px\" dojoType=\" dijit.Editor\">\r\n        It was a dark and
stormy night.  Your story belongs here!\r\n<\/textarea>\r\n<input
type=\"submit\" value=\"Save\"
/>\r\n<\/form>\r\n<\/body>\r\n<\/html>","jcr:primaryType":"nt:unstructured","text":"dddd"
                   }
           }
    }


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....}]

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.

What I meant with not finding the source code to the JCR Property class was
that i did a grep . -exec "javax.jcr.Property" {} \;  -print   and every
file listed was one referering to it, not defining it, except for a jar
file, which came from the jcr project. So I kind of gave up on that point :)

Of course, another idea is to write a new JsonWriter from scratch. It can't
be too hard, and there's a lot of code done already.  I'll try the regexp on
client approach again, first though.

Cheers,
PS


On Jan 22, 2008 9:19 AM, Bertrand Delacretaz <[EMAIL PROTECTED]> wrote:

> Hi Peter,
>
> On Jan 22, 2008 8:00 AM, Peter Svensson <[EMAIL PROTECTED]> wrote:
>
> > ...I did manage to checj out and build Sling alst night, and after a
> while
> > realized that the faulty json stuff is probably due to the fact that
> > javax.jcr.Property does not return tru when a property isMultiple(). Or
> has
> > the wrong ideas of what is multiple. That means that arrays never get
> > generates, but instead all herarchical json objects are just objects
> within
> > objects (which I prefer myself as well, but for some reason isn't
> > 'standard')....
>
> Could you given an example of what JSON you'd expect to get for a
> multivalued property?
>
> I don't think this is tested currently in the microsling-core or
> Launchpad tests, but I'll add it once we define what's needed.
>
> > ...But jcr isn't (of course) included in Sling only tha API jar, so now
> I have
> > to maybe checkout jcr as well and deal with those issues....
>
> Not sure what you mean - the Launchpad and microsling-core both use an
> embedded Jackrabbit repository, so it's all in there.
>
> > ..So, what I've done instead is gone back to the client side and try to
> cram
> > more regexp mojo, so that I can transalte it nearer to home. We'll see
> how
> > it goes....
>
> Ok fine - if you find a way to get what you need, we'll see how we can
> make this happen in Sling!
>
> -Bertrand
>

Reply via email to