Get parameter name from JSON

(Kurt) #1

I need to get the parameter that comes in the API json, which is not a vector. And use only one of the values ​​of the parameters that came. How do I do that?

For example, see the case below.

{
“name”: “Product A”,
“price”: 150,
“features”: {
“speed”: 5,
“weight”: 20
},
“tags”: [
{ “id”: 1 },
{ “id”: 3 },
{ “id”: 5 }
]
}

How could I get the parameter ‘‘name’’ itself, not the value of it (Product A)? I need this because the parameters I get are variable.

Thanks

(Daniel Beckett) #2

You could output the body of the data returned in the webhook. This gives you an option to use the text service to look for matches using regex or to use the code service to do something similar. I believe that you would always need some kind of constant value though so if both the output name and the value of that output change I’m not sure there’s really a way to find a match.

(Joe Hatch) #3

How is the JSON being generated? If it’s dynamic then the ‘key’ (name) is the identifier for the dynamic variable (Product A)

So if you had the JSON in FlowXO and use {{FlowName.data__name}} will return “Product A” (or whatever the value is depending on your JSON output).