Hi David,
Looking at the JsonReader implementation [1] getType
protected int getType(String name, Object object) {
if (object instanceof Double || object instanceof Float) {
return PropertyType.DOUBLE;
} else if (object instanceof Number) {
return PropertyType.LONG;
} else if (object instanceof Boolean) {
return PropertyType.BOOLEAN;
} else if (object instanceof String) {
if (name.startsWith(REFERENCE)) return PropertyType.REFERENCE;
if (name.startsWith(PATH)) return PropertyType.PATH;
if (name.startsWith(NAME)) return PropertyType.NAME;
if (name.startsWith(URI)) return PropertyType.URI;
if (jsonDate.matcher((String) object).matches()) return
PropertyType.DATE;
}
// fall back to default
return PropertyType.UNDEFINED;
}
It appears that type is inferred from the JSON representation itself. And
in some cases from propetyName prefixes. So keeping {"foo":1} should create
foo of type integer
Chetan Mehrotra
[1]
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java?view=markup
On Mon, Apr 30, 2012 at 3:57 AM, David G. <[email protected]> wrote:
> Can someone refresh my memory how to specify property types in a JSON
> file used in a Bundle's initial-content?
>
> I could swear i remember reading it on the Sling site, but can't find it
> again -- i swear that sites randomizes its content every few days just so I
> can't find anything on it :)
>
> I tried using the properties key as seen here:
> http://sling.apache.org/site/content-loading-jcrcontentloader.html
>
> "properties": {
> "foo": {
> "value": 1,
> "type": "Long"
> }
> }
>
>
>
> However that just creates
> .../node/properties/foo.value = [String] 1
> .../node/properties/foo.type = [String] Long
>
> As I would expect.
>
> Thanks
>
> --
> David Gonzalez
> Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
>
>