This is a handy tip for anyone who might be wondering if there's an easy way (a RESTful way) to push hierarchical data into a Java Content Repository, making use of JSON. The good news: There is, indeed, an easy way to accomplish this.

The key is to use the :operation selector (set to a value of "import"), in conjunction with the :contentType selector (set to a value of "json").

Let's take a simple example. Suppose you have a JSON object that looks like:

{ 'jcr:primaryType': 'nt:unstructured',   'propOne' : 'propOneValue',   'childOne' : { 'childPropOne' : true } }

You want this data to show up under /content in the repository tree, with a node of type nt:unstructured. You would simply create a form element in your HTML page and set it up like this:

<form method="POST" action="/content" enctype="multipart/form-data">

   <input type="hidden" name=":operation" value="import" />

   <input type="hidden" name=":contentType" value="json" />

   <input type="hidden" name=":nameHint" value="sample" />

   <input type="text" name=":content"  value="{ 'jcr:primaryType': 'nt:unstructured', 'propOne' : 'propOneValue', 'childOne' : { 'childPropOne' : true } }" />   

<input type="Submit" /> </form>

Once the user clicks "Submit," the JSON data gets pushed into the repository exaxtly where and how you want it.