I am trying output .json files with Component data as its key value pairs. I avoided using regions to avoid <div> tags being inserted. I am pulling the entity fields values directly to the Page view but I still see <html> and <body> tags being added into Page. Is there a way to get these to go away if the o/p file extension is not .html?

  • it will be good if you can share some example. Dec 13, 2017 at 4:05
  • I assume you're using a custom page controller for this? Care to share some of the code and approach you followed?
    – Nuno Linhares
    Dec 13, 2017 at 13:45

1 Answer 1


Views are designed for generating HTML, if you wish to return JSON, you should not abuse the view technology for that (see also the answers to How to remove the HTML content from a Page when Region is used in DXA 1.5 Java?)

Have you tried requesting the URL of a page with ?format=json added to it? Also take a look at ?format=atom and ?format=rss. I suggest to read up on the option of implementing a custom data format (in case the current JSON format is not usable for you), see https://docs.sdl.com/LiveContent/content/en-US/SDL%20DXA-v7/GUID-DF3BDC77-0343-452F-BBB9-9CBA05021183

  • I did tried to use ?format=json but it has lot of information like xpm info/regions/entity details which we dont need.
    – Avinash
    Dec 13, 2017 at 15:37
  • I also look at the other post you mentioned it talks about avoiding the <div> tags that we get by using the regions.I already avoided them. I opted my page template extension to be json, i expected valid json as o/p.It sounded like i need to have custom page controller to get different extension as o/p
    – Avinash
    Dec 13, 2017 at 15:44
  • Again please don’t try that unless you want more work than is needed, I have given you two viable options, use the JSON that is already there or add a custom data format instead Dec 13, 2017 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.