Expose whole page and its components as json

shashi1223 05-11-2019

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.

Accepted Solutions (1)

Accepted Solutions (1)

Arun_Patidar
MVP
22-11-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)

Answers (2)

Answers (2)

shashi1223 22-11-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);