I'm actually posting the answer to this issue because everywhere I searched ALMOST had the answer but nothing I could find matched what fixed my issue.
Issue:
When iterating a webhook response, I am having an issue getting values that only match a specific string.
The webhook response I was getting was in JSON and was like what's seen below.
"data": [
{
"catfood":[]
},
{
"recipe": [
"ingredient": {
"type": "gummybears",
"color": "purple"
}
]
},
{
"recipe":[
"ingredient": {
"type": "gummybears",
"color": "blue"
}
]
},
{
"recipe":[
"ingredient": {
"type": "candycane",
"color": "redwhite"
}
]
},
{
"toothpaste":[]
},
{
"recipe":[
"ingredient":{
"type": "gummybears",
"color": "red"
}
]
}
]
My issue was I wanted to pull ONLY the color of gummybears out of this array and below is what I had to do to accomplish this behavior.
{{#webhookResponse.body.data}} {{#recipe}} {{#ingredient.match(".*(gummybears).*")}} {{color}} {{/}} {{/}} {{/}}
The output this gave me in the end was:
purple blue red
I hope this helps someone else in the future, I spent way too many hours on this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.