cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
grovercorner2
Advocate I
Advocate I

Parse JSON with changing name

How can I loop through or parse the following JSON received from JotForm? The question is in the 'name' part of the JSON, and the answer in the 'value'. The question can change with each response received so I can't use the normal expressions or Parse JSON function. 

 

notepad++_2022-09-02_12-53-53.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @grovercorner2 ,

 

I don't know if it is a solution but I want to share it.

So the key is to get the dynamic field name.

I create a simple sample.

vxiaochenmsft_0-1662537204956.png

split(split(string(variables('var')),'":"')?[0],'"')?[1]
// We can use this expression to extract the field name 
 
vxiaochenmsft_1-1662537319586.png
variables('var')?[outputs('Compose')]
 
vxiaochenmsft_2-1662537348024.png

 

Now we can extract the values from the columns with dynamic name.

But if your data is more complex, the expressions will also be more complex.

 

Best Regards,

Wearsky

View solution in original post

5 REPLIES 5
v-xiaochen-msft
Community Support
Community Support

Hi @grovercorner2 ,

 

Unfortunately, power automate can't parse json with dynamic names.

Please make sure that the name of key is unchanged.

Hopefully it makes sense.

 

Best Regards,

Wearsky

Yes, it makes sense, and I have no idea why a large SAAS provider like Jotform would implement something like this. But sadly there is a 0% chance they will change their API upon my request, and I can't wait for them to release a new version of their API.

v-xiaochen-msft
Community Support
Community Support

Hi @grovercorner2 ,

 

I don't know if it is a solution but I want to share it.

So the key is to get the dynamic field name.

I create a simple sample.

vxiaochenmsft_0-1662537204956.png

split(split(string(variables('var')),'":"')?[0],'"')?[1]
// We can use this expression to extract the field name 
 
vxiaochenmsft_1-1662537319586.png
variables('var')?[outputs('Compose')]
 
vxiaochenmsft_2-1662537348024.png

 

Now we can extract the values from the columns with dynamic name.

But if your data is more complex, the expressions will also be more complex.

 

Best Regards,

Wearsky

grovercorner2
Advocate I
Advocate I

Thanks. I think this is a step in the right direction. But it doesn't take into account the json has multiple rows. How to isolate the first row to use as input to your steps?

v-xiaochen-msft
Community Support
Community Support

Hi @grovercorner2 ,

 

Could you share a json sample?

 

Best Regards,

Wearsky

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (1,491)