The
{{json}} helper safely serializes a value to JSON for inline output in your theme.
This is especially useful when you need to pass server-rendered data into a <script type="application/json"> block or into a JavaScript-powered UI.
Example Code
Passing an object
Passing named values
If you pass hash arguments,{{json}} serializes those named values instead:
Notes
- Returns
nullwhen the input value isundefined - Escapes unsafe characters such as
<,>and&for inline script safety - Intended for JSON output, not for formatting arbitrary HTML

