jackalope/jackalope-jackrabbit — Issue #4: property and child node with same name - invalid json
Author: dbu
Created: 2012-03-09 12:41:13+00:00
State: open

in jcr 2.0, a node may have a property and a child node with both the same name. if you think of it in xml, it makes perfectly sense. if you look at it in the api its weird because the path is identical (as paths do not distinguish node and property).

the json coming back after putting such a structure into jackrabbit looks like this:

{"toast":"bar",":jcr:primaryType":"Name","jcr:primaryType":"nt:unstructured","toast":{}}

there is twice the key "toast", which is not legal in json. php json_decode just overwrites the property "toast" => "bar" with the node array "toast" => array().

on the jackrabbit mailinglist we found that jackrabbit parses json by hand and happens to handle this broken case. see http://www.mail-archive.com/dev@jackrabbit.apache.org/msg28047.html

so either we can try to provide a fix in jackrabbit to have valid json, or make the php client parse the json in a way that handles this broken situation. trying to forbid the feature seems hardly doable to me, at least not without patching jackrabbit as well.

there is testSetPropertyNewExistingNode (deactivated in 12aae16029003863ef688d1800460915ebb3192d ) that demonstrates the problem.