json_encode
To use a filter on a variable in an expression, write the variable then put a |
pipe symbol, then write the filter name:
string|json_encode
This filter has some extra parameters that can be put after the name in brackets:
string|json_encode(options)
Given any object or variable, this returns the JSON representation of a value