The json_value Twig Filter

There is also a special filter you can use to ensure that your JSON keys and values are formatted properly. This filter is available in fields that have the Token Browser icon {t} in the top-right corner of the field.

This filter combines adding the key and value into the json_value filter, in the format:

{{ "your_key" | json_value(your_value) }}

This will ensure that the your key and value are JSON encoded properly, whether it's an integer, boolean, or HTML. When using the json_value you do not need to worry about putting quotes around your values.