I need to create a custom Servlet code where we need to iterate over the children and grandchildren of components on a certain page to create the output json of those components. We could do it using infinity.json OOTB , but we dont want to use the same as those are not recommended to be used in production . also we dont need to output all the components as json , we need to output as per the resource type.
Does anyone has any pointer or reference code to achieve the same.
Solved! Go to Solution.
I think you do not need servlet to achieve your goal. Use Sling Model Exporters feature instead.
Please explore official Adobe documentation to get full set of information in terms of Sling Model Exporter concept and implementation guides:
Hi Lukasz-m ,
The issue is if we add sling model exporter to the components , we need to invoke them on 1 to 1 basis as per the component path , if we hit the Page path , it does not return the json for the components. We have already tried that
hi As mention by @lukasz-m , model.json must do a job.
but if you think you need a custom solution, I created something similar for PoC, you can test try that out
@arunpatidar model.json is not returning the json for custom component on hitting the page directly , if we give the component path then it returns the expected json.
Also regarding the POC you did , does it exports all the custom properties of all the components on the page?
Yes, it basically look for all the nodes inside jcr:content(similar to infinity.json) and export as json.
There is a possibility to blocklist properties