JSON Formatting

NAV IS OUTPUT

Programmable layouts are often utilised to ensure content is safe to be used in JSON output.

A jsonString Custom Helper was created to make this process easier. If you'd like to see the underlying code from this Custom Helper you can check out this doc on Confluence.

How it's used:

{{ jsonString (thing-to-be-escaped) }}

Example

{
  "Plain text": "{{jsonString (publish element="Text element") }}",
  "HTML": "{{jsonString (publish element="HTML element") }}",
  "Media": "{{jsonString (publish element="Media element") }}",
  "List": "{{jsonString (outputSelected(selected element="Checkbox")) }}"
}

 


{
  "Plain text": "This is a text element that contains \"some\" quotes",
  "HTML": "<p>This is a html element.</p>\n<p>There are <span class=\"example\">quotes</span> in here too.</p>",
  "Media": "<img loading=\"lazy\" src=\"/media/sample-site/site-assets/css/css-images/t4u-logo-header.png\" alt=\"\" class=\"\"  />",
  "List": "Name with \"quotes\", Other"
}