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
Register for a Free Workshop.png

Register for a Free Workshop

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

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (1,905)