Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Finding value deep down in a json structure

Svante Gustafsson Björkegren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 25, 2025

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.

EDIT Oct, 1st:

I am still struggling with this and I am now approaching it using @Bill Sheboy solution with Dynamic list searching using a regular expression. The issue I am facing now is that I can't iterate over the field-array: attributes.

I have my variable varAttributes as described, but it does not seem to be a list I can iterate over and use dot-notation. This is what I need to do

{{#varAttributes}}{{objectTypeAttributeId}}:{{.}}~~{{/}}

But it seems it is not a list that I can iterate like this. Is it possible to "convert" it to such a list?

Looking forward to hear back from you!

Cheers,
// Svante

2 answers

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 1, 2025

Hi @Svante Gustafsson Björkegren 

Perhaps the nested structure is recognized as text rather than as an object.

You could test that by using jsonStringToObject() on your branch variable, and then trying to access each attribute:

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#jsonStringToObject--

Kind regards,
Bill

0 votes
Marc - Devoteam
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 25, 2025

Hi @Svante Gustafsson Björkegren 

What if you would simply do: {{webResponse.body.values.attributes.objectTypeAttributeId}}

Do you get all the ID's then?

Svante Gustafsson Björkegren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 1, 2025

Yes, that will give me the attribute-ids but I need to fetch another field in the structure where the id=4853

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events