Data and JSON filters

Serialise a template value to JSON. All are Pagelove extensions.

json

Converts a value to a JSON string. Pass an optional indent for pretty-printing.

{{ request | json }}       <!-- compact -->
{{ request | json: 2 }}    <!-- pretty-printed, 2-space indent -->

jsonify

A Jekyll alias of json — identical output, including the optional indent argument.

{{ request | jsonify }}

inspect

Debug-serialises a value. Template values are acyclic, so this is compact JSON — equivalent to json with no indent. (The name matches Jekyll / LiquidJS, where inspect differs from json only in handling circular references, which do not arise here.)

{{ some_value | inspect }}

See also