Alternative library to jsonWriter to convert page to Json | Community
Skip to main content
New Participant
October 1, 2021
Solved

Alternative library to jsonWriter to convert page to Json

  • October 1, 2021
  • 3 replies
  • 1937 views

Hi all,

 

I am implementing AEM site search functionality using elastic search. My requirement is to extract the page content as json and push it to Elastic search for indexing. I will have to do this on author on an event . 

I have implemented this using com.day.cq.commons.TidyJsonItemWriter and jsonWriter.dump(node, out, 10) which gives me desired output . My concern is, this method throws JSONException which is of class org.apache.sling.commons.json.JSONException; and its a deprecated hence i don't want to use it . Could some one suggest what would be the best way to achieve json dump for my page content including all the components in a page.

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

Hi,

You can use gson from google.

Example https://aemlab.blogspot.com/2019/07/get-json-response-of-aem-page.html

3 replies

arunpatidar
arunpatidarAccepted solution
New Participant
October 3, 2021
Arun Patidar
aem_savyAuthor
New Participant
October 4, 2021

Thanks for the response . This looks good as alternative to get the Json dump . 

Kishore_Kumar_
New Participant
October 3, 2021
aem_savyAuthor
New Participant
October 4, 2021

Hi , 

 

The solution in that thread can not be applied in my case as I want to extract the json dump of the content for already built components and pages  so that i can index the content in elastic cache. Thank you so much for the response

joerghoh
Employee
October 2, 2021

Although Sling Commons JSON is deprecated, it's not going to be removed in the AEM product anytime soon (at least until a replacement is provided).

If it works right now for you, I would stick with it.

aem_savyAuthor
New Participant
October 4, 2021

Thanks for the response . I might just stick with Json writer for now in that case