Filters
json_encode
Introduction
The json_encode
filter converts a variable—such as an array or object—into a JSON-formatted string. This filter is especially useful when you need to pass data from a Twig template to a JavaScript script or an API that consumes JSON.
Example of use
Example of how to use the json_encode
filter to convert an array into a JSON string: