Hey,
I am trying to fetch a value inside a JSON structure and I cannot get it right. Maybe this community can give me a hint how to write my smart value variables for this use case
Background: I have read up a bunch of Assets objects via the Assets REST API end point: /object/aql. The webResponse is an array of objects under the "values" tag.
I create a branch from the {{webResponse.body.values}} smart value and call the branch variable myObject. So far so good. In each object structure in the array there is an attributes-array called attributes. In this array I need to get the value for an attribute with a specific attribute-id.
The structure looks like this (simplified):
{
"values": [
{
"id": "20",
"attributes": [
{
"objectTypeAttributeId": "4839",
"objectAttributeValues": [
{
"displayValue": "Some attribute value"
}
]
},
{
"objectTypeAttributeId": "4853",
"objectAttributeValues": [
{
"displayValue": "This is my value to fetch"
}
]
}
]
},
{
"id": "21",
--- the next object ---
In my branch I create a variable to get the attribute array:
varAttributes --> {{myObject.attributes}}
This works fine. But I can't get down to the requested attribute-id from here. I would like to create a variable that gives me the value "This is my value to fetch", i.e. the value from the attribute with ID "4853".
I have tried a number of variants of setting a new variable to something like: {{#varAttributes}}{{.}}{{/}} and some if-clause that tests for the ID value, but I can't get it right.
Looking forward to hear back from you!
Cheers,
// Svante