1``json_encode`` 2=============== 3 4The ``json_encode`` filter returns the JSON representation of a value: 5 6.. code-block:: jinja 7 8 {{ data|json_encode() }} 9 10.. note:: 11 12 Internally, Twig uses the PHP `json_encode`_ function. 13 14Arguments 15--------- 16 17* ``options``: A bitmask of `json_encode options`_: ``{{ 18 data|json_encode(constant('JSON_PRETTY_PRINT')) }}``. 19 Combine constants using :ref:`bitwise operators<template_logic>`: 20 ``{{ data|json_encode(constant('JSON_PRETTY_PRINT') b-or constant('JSON_HEX_QUOT') }}`` 21 22.. _`json_encode`: https://secure.php.net/json_encode 23.. _`json_encode options`: https://secure.php.net/manual/en/json.constants.php 24