Expand my Community achievements bar.

SOLVED

Right way to save very big string json

Avatar

Level 6

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?

1 Accepted Solution

Avatar

Correct answer by
Level 5

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!!

View solution in original post

2 Replies

Avatar

Community Advisor

Hi @arvind,

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

[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

Avatar

Correct answer by
Level 5

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!!