Webhooks with JSON arrays or nested objects escaping quotes

There’s no way to do this right now.

This is a similar issue to {{PARTICLE_EVENT_VALUE}} gets HTML encoded: how to get values that are not strings into webhooks.

I’d favor the same syntax I recommended in that other post:

Allow the use of Javascript conversion methods like JSON.parse() in the template and skipping the quotes in the generated JSON if the result is an object or array.

"json": { "myarray": "{{JSON.parse(somedata)}}" },

Actually I just realized that JSON.parse can accomodate all these use cases:

JSON.parse("10") // 10
JSON.parse("true") // true
JSON.parse("1.5") // 1.5
JSON.parse("[{\"id\":\"1234\"}]") // [{"id":"1234"}]

So @Dave, how about adding a parse filter to the webhook format processor to be able to include numbers, booleans, arrays and object in the webhook?

"json": { "myarray": "{{parse(somedata)}}" },

1 Like