Expose whole page and its components as json | Community
Skip to main content
Shashi_Mulugu
Community Advisor
Community Advisor
November 5, 2019
Solved

Expose whole page and its components as json

  • November 5, 2019
  • 3 replies
  • 2494 views

Hello arunpatidar26​, kautuksahni​, Do you have any suggestions over generating whole page and its associated components as json. We are using sling model exporters, and using .model.json for getting the json out of a resourcetype, but wanted to know what we can do if we want to expose whole properties and components.

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

Yes, you can try. but make sure you exclude properties before getting a Model from the resource.(Setting exclude property value to null can help)

3 replies

arunpatidar
Community Advisor
Community Advisor
November 5, 2019

you need to write custom implementation

example - AEM - Get JSON response of an AEM Page

Arun Patidar
Shashi_Mulugu
Community Advisor
Community Advisor
November 22, 2019

Hello Arun,

Need your inputs, I have went through your custom implementation, can't we use something as below to iterate to child resource and inject its own models and adapt to json instead of manually transforming node to json, maintaining custom ignore properties and all?

Resource resource = resourceResolver.getResource("/mysite/component/breadcrumb");
slingScriptHelper.getService(ModelFactory.class).getModelFromResource(resource);

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
November 22, 2019

Yes, you can try. but make sure you exclude properties before getting a Model from the resource.(Setting exclude property value to null can help)

Arun Patidar