Right way to save very big string json | Adobe Higher Education
Skip to main content
Level 5
November 21, 2022
Risolto

Right way to save very big string json

  • November 21, 2022
  • 2 risposte
  • 1306 visualizzazioni

Hi Team,

 

AEM : 6.5.12

 

We need to save a very BIG JSON String of size around 3.5 MB, in a node property.

 

What is right way to save? Just as a String data type? or should be saving as a Binary data?

Questo argomento è stato chiuso alle risposte.
Migliore risposta di VeenaK

It is better to store the value as binary instead of string, for more improved performance you can upload this as dam file and refer the path of the JSON in a property.

This approach may have its impacts if your application performs search on this property.

So, I recommend to store them as binary as property itself.

Hope this is helpful!!

2 risposte

SantoshSai
Community Advisor
Community Advisor
November 21, 2022

Hi @arvind-1,

Why don't you upload the JSON file as asset (just as you would upload images) and deliver access it as is? - IMHO, this would be the best way to deliver a performant AEM website than saving such a big JSON on node. References [0],[1].

However, to answer your question: 

  1. Write a custom AEM service and then use JCR API to update the node.
    Parse the values from JSON and then use API to update the nodes in the JCR.
    eg.
    //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);

References:

[0]: https://blogs.perficient.com/2021/08/16/loading-json-content-into-aem/

[1]: https://aemsimplifiedbynikhil.wordpress.com/2019/10/04/read-write-data-in-json-file-of-dam-in-aem-making-rest-api-call/

[2]: Adobe Experience Manager Help | Persisting Adobe Experience Manager data in the Java Content Reposit... 

  • If the Json data is huge then There are many libraries for serializing/deserializing JSON in java, the most notable is Google’s Gson: https://github.com/google/gson

Hope that helps!

Regards,

Santosh

Santosh Sai
VeenaKRisposta
Level 4
November 21, 2022

It is better to store the value as binary instead of string, for more improved performance you can upload this as dam file and refer the path of the JSON in a property.

This approach may have its impacts if your application performs search on this property.

So, I recommend to store them as binary as property itself.

Hope this is helpful!!