Trigger a JSON layout rendering

Abstract

SXA enables you to model your data in JSON (JavaScript Object Notation). For example, if you want to build a mobile app and feed it with SXA content, you can edit the JSON content on the page and have output content in JSON instead of HTML.

To trigger JSON output, you can:

  • Trigger JSON output using device id .You can include the device id in the URL. Use sc_device to change the device in which the website is displayed. You can use the device name or the device id. For example, if you have a JSON layout defined for this page:

    http://sxa18//json-content

    Modify it by adding the sc_device query string:

    http://sxa18//json-content?sc_device={0B4A31C9-712D-4578-A396-2DDC0F34B63A}

    or

    http://sxa18/json-content?sc_device=json

  • Trigger a device change with HTTP headers using HTTP header .Set the application/json value for the ContentType header. For example, invoke with Powershell:

    Invoke-WebRequest "http://sxa18//json-content" -ContentType "application/json"