I'm receiving JSON data from a service call programatically.
Now, I want to save/upload the JSON data to the JCR as a .txt file programatically. What is the best approach to achieve this ?
Appreciate your help. Thanks!
Solved! Go to Solution.
+1 with Scott solution.
Adding few extra reference articles here:
// Create JCR nodes from json string
Link:- http://asserttrue.blogspot.in/2012/05/importing-json-data-into-java-content.html#
//Importing JSON data into a Java Content Repository
I hope this would help you.
~kautuk
Views
Replies
Total Likes
Write a custom AEM service and then use JCR API to update the nodes.
Parse the values from JSON and then use API to update the nodes in the JCR -- for example:
//Store content from the client JSP in the JCR
Node custNode = customerRoot.addNode("customer"+firstName+lastName+custId,"nt:unstructured");
//make sure name of node is unique
custNode.setProperty("id", custId);
custNode.setProperty("firstName", firstName);
custNode.setProperty("lastName", lastName);
See: https://helpx.adobe.com/experience-manager/using/persisting-cq-data-java-content1.html
This will point you in the correct direction.
+1 with Scott solution.
Adding few extra reference articles here:
// Create JCR nodes from json string
Link:- http://asserttrue.blogspot.in/2012/05/importing-json-data-into-java-content.html#
//Importing JSON data into a Java Content Repository
I hope this would help you.
~kautuk
Views
Replies
Total Likes
smacdonald2008 wrote...
Write a custom AEM service and then use JCR API to update the nodes.
Parse the values from JSON and then use API to update the nodes in the JCR -- for example:
//Store content from the client JSP in the JCR
Node custNode = customerRoot.addNode("customer"+firstName+lastName+custId,"nt:unstructured");
//make sure name of node is unique
custNode.setProperty("id", custId);
custNode.setProperty("firstName", firstName);
custNode.setProperty("lastName", lastName);
See: https://helpx.adobe.com/experience-manager/using/persisting-cq-data-java-content1.html
This will point you in the correct direction.
Thank Scott for the reply. I'm dealing with huge data so I think parsing the json and adding it in the repo takes down the performance. I was wondering if there is a way to have my response (from the service call) directly save in the JCR !!
Views
Replies
Total Likes
Check the links that Kautuk added. In the tools we have coded for AEM - we have always used the JCR/JCR SQL2 to do the job.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies