cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Martin260
Frequent Visitor

Parse JSON - Dynamic Object as field name

Hello,

I am having some trouble with dynamic field names that are breaking the parse Json in my process. For example, if I have two different field numbers ("405", "403") If I set the schema to have the field header as "405" it will work for the first, but not the second. Is there any way to make these field headers parseable through the JSON schema?  

 

 

{
    "405": {
        "id": 405,
        "Title": "BlankUsername",
        "Name": "Null"
    },
    "403": {
        "id": 403,
        "Title": "BlankUsername",
        "Name": "Null"
    }
}

 

 

Many Thanks in Advance

1 ACCEPTED SOLUTION

Accepted Solutions

Here is a working example flow:

2021-11-17_13-16-40.png2021-11-17_13-19-54.png

(3) Expression for Compose Reformat:

json(concat('[',replace(outputs('Compose_String'),'},''}},{'),']'))

2021-11-17_13-20-05.png

(4) Select Expression for Map:

json(concat('{',replace(last(split(string(item()),'{')), '}}','}')))

2021-11-17_13-20-14.png

(5) Apply to Each loop

2021-11-17_13-22-59.png

 

2021-11-17_21-55-50.png

Hope this helps.


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

View solution in original post

5 REPLIES 5
ekarim2020
Super User
Super User

If the data was transformed and formatted as an array as shown below, could your flow make use of the data in this format?

[
  {
    "id": 403,
    "Title": "403BlankUsername",
    "Name": "Null"
  },
  {
    "id": 405,
    "Title": "405BlankUsername",
    "Name": "Null"
  }
]

 

You could loop through each item in the array (403, 405) and reference each of the properties id, Title and Name with needing to use the Parse JSON action:

2021-11-12_21-14-30.png

 


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

@ekarim2020  Thanks you for this response.

 

Unfortunately, there is no easy way of removing this from the response string (apart from using regular expression in PAD, which usually causes the process to take a long amount of time). 

 

I'll try to find a workaround with what you have given me in the meantime.

 

Kind Regards, 

Martin 

We can write a flow to take the data you already have and format the data as:

 

[
  {
    "id": 403,
    "Title": "403BlankUsername",
    "Name": "Null"
  },
  {
    "id": 405,
    "Title": "405BlankUsername",
    "Name": "Null"
  }
]

 

 

Could you then use that data structure within your flow? You could then reference each property

2021-11-17_13-14-20.png

 

Ellis

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

Here is a working example flow:

2021-11-17_13-16-40.png2021-11-17_13-19-54.png

(3) Expression for Compose Reformat:

json(concat('[',replace(outputs('Compose_String'),'},''}},{'),']'))

2021-11-17_13-20-05.png

(4) Select Expression for Map:

json(concat('{',replace(last(split(string(item()),'{')), '}}','}')))

2021-11-17_13-20-14.png

(5) Apply to Each loop

2021-11-17_13-22-59.png

 

2021-11-17_21-55-50.png

Hope this helps.


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

@ekarim2020 Thank you for all your help, this solution has worked perfectly. 

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.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (3,241)