cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Chriss1982
Helper I
Helper I

Filter JSON or convert JSON to an array

Hi all,

 

I have a JSON as below and want e.g. the value for the second entry ("ID": "51979307"). How could I do that?

 

"Title": "Improvement Request",
"Options": [
{
"ID": "59961274",
"Type": "TextField",
"Title": "1. Nice to have you here! Give your improvement ticket a title. ",
"Value": "Test Ticket for Power Automate Flows",
"Required": true,
"Description": "",
"OrderNumber": "1.",
"DefaultValueEnabled": false
},
{
"ID": "51979307",
"Type": "TextBox",
"Title": "2. Describe your improvement suggestion/ request briefly. ",
"Value": "Description for Test Ticket for Power Automate Flows",
"Required": true,
"Description": "",
"OrderNumber": "2.",
"ExtraSettings": "PlaintText"
},

(...)

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Pstork1
Dual Super User
Dual Super User

You can use Index integers in JSON to access a specific entry in an array.  Assuming your JSON is in a Parse JSON something like this

Outputs('Parse JSON')?['Options'][1]?['ID']

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

I would use a filter array action to filter only the rows where checked = true from the Value array.  Then you can access that value using the syntax in my previous post

body('Filter_array')[0]?['Name of key to retrieve']


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

7 REPLIES 7
Pstork1
Dual Super User
Dual Super User

You can use Index integers in JSON to access a specific entry in an array.  Assuming your JSON is in a Parse JSON something like this

Outputs('Parse JSON')?['Options'][1]?['ID']

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Thank you @Pstork1 !
Do you have any idea how to get value from the one below which is "true" ?

"ID": "66148365",
"Type": "Choice",
"Title": "3. What does your improvement ticket relate to?",
"Value": [
{
"key": 16904642,
"text": "D365",
"checked": false
},
{
"key": 75204053,
"text": "Teams",
"checked": false
},
{
"key": 6244205,
"text": "New non-standard equipment",
"checked": false
},
{
"key": 22950821,
"text": "New non-standard software license ",
"checked": false
},
{
"key": 31783402,
"text": "New solution (system, app, portal, etc.)",
"checked": false
},
{
"key": 90172441,
"text": "Other",
"checked": true
}

I would use a filter array action to filter only the rows where checked = true from the Value array.  Then you can access that value using the syntax in my previous post

body('Filter_array')[0]?['Name of key to retrieve']


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Thanks @Pstork1 for your reply. How can I filter an json?

This does not work:

Chriss1982_0-1669926204086.png

 

 

You'll probably need to do a Parse JSON first to gain access to the Checked column.  I copied your JSON and ended up with this to get the key value for the entry where checked = true

image.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

May I ask you to copy and paste the schema which you used?

I just created a schema from the JSON.  However, the JSON you posted is incomplete so I had to add a closing square bracket to close the array and an opening and closing brace to close the object.  I assumed what you posted was a fragment of a larger JSON entry.  What you posted isn't valid JSON.  Here's what I changed it to.

{
"ID": "66148365",
"Type": "Choice",
"Title": "3. What does your improvement ticket relate to?",
"Value": [
{
"key": 16904642,
"text": "D365",
"checked": false
},
{
"key": 75204053,
"text": "Teams",
"checked": false
},
{
"key": 6244205,
"text": "New non-standard equipment",
"checked": false
},
{
"key": 22950821,
"text": "New non-standard software license ",
"checked": false
},
{
"key": 31783402,
"text": "New solution (system, app, portal, etc.)",
"checked": false
},
{
"key": 90172441,
"text": "Other",
"checked": true
}
]
}



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,136)