cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Extracting Nth Value from JSON Array

Hi!

 

I'm wondering how to get the nth value from this array. In my situation, I would need to parse through all three below but not sure how to retrieve these values (effectively). I'm piggy backing from this post I made (same concept).

 

Thank you!

 

"ToughnessTemperature": [
  {
    "Key": "DropWeightTearTesting",
    "Value": null
  },
  {
    "Key": "ImpactCharpyTesting",
    "Value": null
  },
  {
    "Key": null,
    "Value": null
  }
]

 

 

ProfileCrater3_0-1613770313286.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User
Super User

From: 

outputs('JSON')['ToughnessTemperature']

Map: 

 

concat
(
  '"', 
  item()['Key'], 
  '": "',
  item()['Value'],
  '"'
)

 

The JSON you posted isn't valid and needs to have { and } prepended and appended for these expressions to work. Produces:

 

{
  "DropWeightTearTesting": "",
  "ImpactCharpyTesting": "",
  "": ""
}

 

View solution in original post

8 REPLIES 8
Paulie78
Super User
Super User

Not this again! 🤮

Anonymous
Not applicable

@Paulie78 Yes, unfortunately😕. But, good news, this is the last array I need help with. The rest I can handle (hopefully).

Paulie78
Super User
Super User

I’d do it for you but I’m not near a computer - why not copy the method from the previous post?

Anonymous
Not applicable

@Paulie78 Trust me, I've tried. I tweaked and tweaked the expression but I keep getting an error. I tried over 15 different expressions with no luck...hence why I am back😅

Anonymous
Not applicable

@Paulie78 I think I got it. It might be:

outputs('JSON')['ToughnessTemperature'][1]['Value']

Tying it out now! 

Paulie78
Super User
Super User

From: 

outputs('JSON')['ToughnessTemperature']

Map: 

 

concat
(
  '"', 
  item()['Key'], 
  '": "',
  item()['Value'],
  '"'
)

 

The JSON you posted isn't valid and needs to have { and } prepended and appended for these expressions to work. Produces:

 

{
  "DropWeightTearTesting": "",
  "ImpactCharpyTesting": "",
  "": ""
}

 

Paulie78
Super User
Super User

The way you are trying it will also work, arguably simpler and easier. Wouldn't have worked for the one you posted yesterday, but this one it should.

Anonymous
Not applicable

@Paulie78 Yup, it surely did work! Thank you! Hopefully I won't be back anytime soon lol

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,416)