Output content as JSON

With a combination of Template, Format, and Output, you can publish your page content as a JSON file.


Create a Template using skip tags and a "dummy" surrounding element:

<!--#cascade-skip--><pass-through><system-region name="DEFAULT"/></pass-through>


Generate valid JSON content and surround that content with a #protect-top code section. In Velocity, the SerializerTool.toJson method can be used to convert an XML string or JDOM Element to JSON.

Velocity example:

#set ($callingPage = $_XPathTool.selectSingleNode($contentRoot, "//calling-page/system-page"))
$_SerializerTool.toJson($callingPage, true)

XSLT example:

...JSON content here...


Create a new Output in your page Configuration with the following settings:

  • Type of Data: JSON
  • File Extension: .json
  • Template: choose the Template you created earlier.
  • Regions: apply the Format you created earlier and a calling page Index Block to the DEFAULT region.