Expand my Community achievements bar.

SOLVED

Get the all components data from the current page to create the customized JSON

Avatar

Level 1

I am working in one of the requirement where I need to create the page JSON form the all available components on the page . I tried to create the workflow process in the custom process I tried to get the all the current page's components but I am not able to get the all the component nodes and also not able to read the properties of the components.  I am not using SPA.

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi @anamikapatle ,

You can use sling model exporter functionality to export component properties into customized JSON

Refer -

1) https://medium.com/@toimrank/aem-sling-model-exporter-90dc872835b9
2) http://www.sgaemsolutions.com/2017/06/sling-model-exporter-in-aem-63.html

Thanks,
Manisha

 

 

View solution in original post

5 Replies

Avatar

Level 6

Hi,

OOTB AEM json exporter can deliver the content of any AEM page as json format.

eg:- localhost:4502/content/wknd/language-masters/en.model.json 

This may help in achieving the objective . Pls check the below link :-

https://experienceleague.adobe.com/docs/experience-manager-64/developing/components/json-exporter.ht...

 

Thanks,

Somen

Avatar

Correct answer by
Level 2

Hi @anamikapatle ,

You can use sling model exporter functionality to export component properties into customized JSON

Refer -

1) https://medium.com/@toimrank/aem-sling-model-exporter-90dc872835b9
2) http://www.sgaemsolutions.com/2017/06/sling-model-exporter-in-aem-63.html

Thanks,
Manisha

 

 

Thanks @Manisha_Mirchandani  I have written the sling model exporter for all the components but I am not getting how will I use this model.tidy.json in my service or servlet class. I tried to write the http request but not getting any response from the model. 

Hi @anamikapatle,

 

Can you please clarify the requirement?

As per understanding we use sling model exporter to export the data in the form of JSON to avoid writing servlet for the same.

 

Manisha_Mirchandani_0-1680193408341.png

 

Thanks,

Manisha

 

Avatar

Community Advisor

Sling model is bind with the component so to check if sling model is working or not you need to go to the component path in the page node then try with model.json. You will able to get the custom that as json that are getting exposed from sling model. 
in order to expose the json data from page path.model.json you need to write another sling model that will be bind to the template level component and on that sling model exporter you have ti query or traverse or sling resource for the page and call the corresponding sling model for that component. That’s the one way of doing this and you can design something similar that you think suited best for your use case. There is not standard recommendations on this.