You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Michael Marth <mm...@day.com> on 2008/09/23 12:26:54 UTC

prefix :jcr: in json

Hi,

for the json presentation of nt:resource nodes I get one property with
prefix :jcr: instead of jcr:. Is this the expected behavior?

      "Creek.jpg":{
         "jcr:created":"Tue Sep 23 2008 10:44:54 GMT+0200",
         "jcr:primaryType":"nt:file",
         "jcr:content":{
            "jcr:uuid":"2cd77618-dae5-4e45-bd91-800da6bf48cf",
            *":jcr:data":264409,*
            "jcr:mimeType":"image/jpeg",
            "jcr:lastModified":"Thu Sep 04 2008 14:44:56 GMT+0200",
            "jcr:primaryType":"nt:resource"
         }
      }

(using the Sling version that came with CRX Quickstart)

Michael

-- 
Michael Marth | Day JCR Cup 08 | Win a MacBook Pro: http://dev.day.com/

Re: prefix :jcr: in json

Posted by Carsten Ziegeler <cz...@apache.org>.
Bertrand Delacretaz wrote:
> 
> although the "we dump the length and not the length" comment is not
> too helpful ;-)
And with the power of open source I was able to change the comment :)

Carsten

-- 
Carsten Ziegeler
cziegeler@apache.org

Re: prefix :jcr: in json

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Tue, Sep 23, 2008 at 12:55 PM, Tobias Bocanegra
<to...@day.com> wrote:
> ..i think this is intended and the value is the length of the binary property....

Yes that's correct, I had to dig up the corresponding code to find
out, in JsonResourceWriter:

// special handling for binaries: we dump the length and not the length
        if (value instanceof InputStream
            || (values != null && values[0] instanceof InputStream)) {
            // TODO for now we mark binary properties with an initial colon in
            // their name
            // (colon is not allowed as a JCR property name)
            // in the name, and the value should be the size of the binary data
            w.key(":" + key);
            if (values == null) {
                writeLength(w, valueMap, -1, key, (InputStream)value);
            } else {
                w.array();
                for (int i = 0; i < values.length; i++) {
                    writeLength(w, valueMap, i, key, (InputStream)values[i]);
                }
                w.endArray();
            }
            return;
        }


although the "we dump the length and not the length" comment is not
too helpful ;-)
-Bertrand

Re: prefix :jcr: in json

Posted by Tobias Bocanegra <to...@day.com>.
hi,
i think this is intended and the value is the length of the binary property.
regards, toby

On 9/23/08, Michael Marth <mm...@day.com> wrote:
> Hi,
>
>  for the json presentation of nt:resource nodes I get one property with
>  prefix :jcr: instead of jcr:. Is this the expected behavior?
>
>       "Creek.jpg":{
>          "jcr:created":"Tue Sep 23 2008 10:44:54 GMT+0200",
>          "jcr:primaryType":"nt:file",
>          "jcr:content":{
>             "jcr:uuid":"2cd77618-dae5-4e45-bd91-800da6bf48cf",
>             *":jcr:data":264409,*
>             "jcr:mimeType":"image/jpeg",
>             "jcr:lastModified":"Thu Sep 04 2008 14:44:56 GMT+0200",
>             "jcr:primaryType":"nt:resource"
>          }
>       }
>
>  (using the Sling version that came with CRX Quickstart)
>
>  Michael
>
>
>  --
>  Michael Marth | Day JCR Cup 08 | Win a MacBook Pro: http://dev.day.com/
>