cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Haraziym
Regular Visitor

parsing json get value of json object with numeric properties names dynamically

I'm  trying to get values of json object with numeric properties names dynamically for a project.

 

 how create a loop to pass the name dynamically .I tried variables('') [items('loop')] did not work I tried to convert to XML but since the node start with a number it will not work i tried change the property name could not find a way. any idea how to  get the value for such cases?

 

1.PNG

 

 

2.PNG

 

4455

 

 

 

4 REPLIES 4
manuelstgomes
Super User
Super User

Hi @Haraziym 

 

In your variable with the JSON declare it as a String. Then use a compose with the following formula:

json(variableName)

 

After this, in the loop you can access each value using, in the compose:

item()

 This will fetch the current item. If you want to fetch the item that has the key "2017" you can do in the compose:

items('Loop')?['2017']

 

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

Cheers
Manuel

Hi

Thanks for the reply, that will work if the item is declared , what i need to fetch each item dynamically i.e. 2017,2018, 2019. 

 

items('Loop')?[item()]

 

i tried this but gives an error .

 

Hi @Haraziym 

 

The item() should contain both values. Then you can parse them easily.

 

If it returns an error message please paste it here so that I can help you

 

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

Cheers
Manuel

i get the error below

InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '1' and column '2147': 'The template language expression 'items('Loop')?[item()]' cannot be evaluated because property '2017' cannot be selected. Property selection is not supported on values of type 'Integer'. Please see https://aka.ms/logicexpressions for usage details.'.

Helpful resources

Announcements
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.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (1,208)