Skip to content

property and child node with same name - invalid json #4

@dbu

Description

@dbu

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).

<test toast="bar">
    <toast/>
</test>

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/[email protected]/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 12aae16 ) that demonstrates the problem.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions