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 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 (5,876)