I was also referencing the java parser that is used to load JSON node
definitions, I apologize for not being clear enough in the first post.
If you have a node property of type date and try to set it via a JSON
definition file using the Content Loader, it will throw an exception
that there is no matching property definition. That exception is only
thrown when applying properties to an nt:file, example is below. If
you apply it to an nt:unstructured with the same mixin, it falls back
to the wildcard property and is a string, not a date, in the jcr. So
as far as I can tell, and after a look over of the JSON parser, the
JSONObject's parsing doesn't create date properties as it should.
I'm wondering if I missed something, if this is by intention, or is
this a missing feature of the parser.
Example:
mixdef.cnd
[melt:development] > mix:referenceable mixin
- 'melt:testdate' (date)
test (regular file)
test.json
{
"jcr:mixinTypes": ["melt:development"],
"melt:testdate": "2001-09-11T08:46:54.172-04:00"
}
21.09.2009 11:31:25.347 *ERROR* [OsgiInstallerThread]
org.apache.sling.jcr.contentloader.internal.Loader Cannot load initial
content for bundle disease-ed-portal : no matching property definition
found for {http://www.meltmedia.com/jcr/sling/1.0}testdate
javax.jcr.nodetype.ConstraintViolationException: no matching property
definition found for {http://www.meltmedia.com/jcr/sling/1.0}testdate
On Sep 21, 2009, at 2:59 AM, Alexander Klimetschek wrote:
On Sat, Sep 19, 2009 at 00:15, Josh Kennedy <[email protected]>
wrote:
One thing I noticed is that neither the sling.json, nor the actual
json
library account for handling dates (ex: json.put("myDate",
java.util.Date)).
What is the preferred method for using a date type with json
property
descriptors? There are some json java implementations which will
serialize
java dates into the Date(xxx) in the json string. I haven't looked
through
the code for the json parser to see if theirs handles it properly,
but
through testing, I haven't gotten it to work with the sling json.
Sling will serialize a JCR Date object (java.util.Calendar) as String
in the (standard) Javascript/ECMA Date format, so that it can be
easily parsed on the client side:
new SimpleDateFormat("EEE MMM dd yyyy HH:mm:ss 'GMT'Z", Locale.US)
Regards,
Alex
--
Alexander Klimetschek
[email protected]