Hi,
We need to come up with an encoding scheme for JCR values in JSON. While
String and Boolean are straight forward double, long and decimal are
already more troublesome. Finally for binary, date, name, path,
reference, weakreference and uri there is no direct correspondence in JSON.
The way I solved this in spi2microkernel [1] is by encoding values by
serializing them to their string representation (Value.getString()) and
prepend its property type (value.getType) in radix 16 and a colon (:).
So "A:123" would stand for a decimal value of 123. Boolean, long and
some strings don't need the "x:" pre-amble since they can be
unambiguously encoded to the respective JSON representation. Only String
where the second character is a colon need the "x:" preamble for
disambiguation:
"example":{
"long":123,
"another long":"3:124",
"double":"4:123.4",
"string":"foo",
"another string":"1:a:string"
}
WDYT? Other suggestions?
On a related note: what kind of values do we want to expose from
oak-core? JSON like or JCR like? Implementation wise, would that
en/decoding happen inside oak-jcr or oak-core?
Michael
[1]
http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/Values.java?view=markup