Expand my Community achievements bar.

SOLVED

Expose whole page and its components as json

Avatar

Community Advisor

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.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

3 Replies

Avatar

Community Advisor

you need to write custom implementation

example - AEM - Get JSON response of an AEM Page



Arun Patidar

Avatar

Community Advisor

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);

Avatar

Correct answer by
Community Advisor

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