Twig how to add options to json_encode

In twig, you can add filter json_encode which internally is using json_encode php function.

Now to add options just like json_encode in php,

{{ data | json_encode(constant('JSON_HEX_APOS')) | raw }}

to add more than one option you can use b-or operation to have multiple json_encode options:

{{ pageData|json_encode(constant('JSON_HEX_APOS') b-or constant('JSON_HEX_QUOT') ) | raw }}
Total Views: 17 ,