Liquid `json` filter used in ticket triggers/webhooks has unexpected results.
Posted Apr 08, 2025
Liquid has a filter called `json` that converts an object into a JSON string. This would be extremely convenient for webhooks, as it would allow admins to easily construct JSON strings with these objects and send them to their applications.
However, Zendesk's implementation of the Liquid `json` filter seems to be having unexpected results when compared to the Shopify Documentation and Liquid JS Implementation.
What should happen is that for an array, the array should be converted to an array of strings and then stringified, creating a valid JSON string. Here is an example:
{
"origin": "My Webhook",
"ccs": {{ ticket.ccs | map: "email" | json }}
}
Which should result in this valid JSON string:
{
"origin": "My Webhook",
"ccs": ["first@test.com","second@test.com"]
}
However, Zendesk's liquid implementation escapes the quotation marks, resulting in invalid JSON:
{
"origin": "My Webhook",
"ccs": [\"first@test.com\",\"second@test.com\"]
}
The Shopify documentation does mention that the json filter will escape any quotes in the output, but as can be seen in their example, this does not mean that the quotations around the strings themselves should be escaped. Unless I am understanding the structure of the ticket.ccs object wrong, this is a mistake in Zendesk's implementation.
1
1 comment
Sign in to leave a comment.