May 10, 2020
Estimated Post Reading Time ~

Storing JSON string in .content.xml

Given the JSON string of:
{ "firstname" : "Owen", "lastname" : "Bringino", "country" : "Philippines" }

If the above JSON string will be assigned as property value inside an XML document, then it will be encoded as:
"{"firstname":"Owen","lastname":"Bringino",
"country":"Philippines"}"

However, you may need to explicitly cast it to String when defined inside .content.xml as shown in the code snippet below:

<jcr:root ...>
    <jcr:content ...>
        <record jcr:primaryType="nt:unstructured"
            member= "{String}{&quot;firstname&quot;:&quot;Owen&quot;,
                     &quot;lastname&quot;:&quot;Bringino&quot;,
                     &quot;country&quot;:&quot;Philippines&quot;}" />   
    </jcr:content>
</jcr:root>

Without the {String} type hint, you may not be able to see the "member" property in JCR/CRXDE after deployment or upload.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.