I am trying to iterate through the resources inside a page. In my code I am able to get the resource but while iterating i only managed to get the last component inside the page. I need to get each resource and its properties so that I can write a json for each resource. The snippet which i have written is as follows:
You need to create a recursive method which traverses down the resource tree. You can find an quite extensive example in the JSON renderer of the DefaultGetServlet of Sling, which does the same functionality.