web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Parse JSON always retu...
Power Automate
Unanswered

Parse JSON always returning an error

(0) ShareShare
ReportReport
Posted on by 34

I am getting a very frustrating issue with the Parse JSON action.

My flow is checking if a particular file is added to a folder, then extracts the XML from that file with one Compose Action, then converts that to JSON  with another Compose action.

 

When I take the output of the second Compose action and use that to generate a schema in Parse JSON, i get an error saying "Expected Object but got Array."

 

Object Array Error.png

 

Now, I've checked the output of the Compose JSON Step and it's definitely NOT an Array. The JSON output has confidential info and has over 3k records in it so I can't post the whole record here but if you see the start it's definitely an Object and not an array.

 

JSON Start.png

 

And what's weirder, is if I generate the Schema to expect an array by enclosing the output of Compose Action in []...

Array Schema.png

 

... I get the OPPOSITE error: "Expected Array but got Object".

 

Array Object Error.png

 

In both cases, the source file and the output of the JSON Compose action is identical, the only difference is whether i added [] to the sample payload when generating the schema.

How can it possibly be that in one case it's failing with "Expected Object but got Array" but when I told it to expect an Array it failed with "Expected Array but got Object"?

Categories:
I have the same question (0)
  • Verified answer
    Pstork1 Profile Picture
    68,697 Most Valuable Professional on at

    The error is a type error.  So I suspect the problem is that you have elements in the JSON that are sometimes objects and sometimes an array of objects.  That can definitely happen when converting XML to JSON.  The problem is that XML isn't consistent in requiring a parent (array) element when including multiple elements.  So you may have output that looks like this

    <root>

    <item1>

    <attribute>

    </attribute>

    <item1>

    <item2>

    <attribute>

    </attribute>

    <attribute>

    </attribute>

    <item2>

    </root>

    Attribute will translate to an object in JSON for Item1 and an array for Item2.  I think that is what is happening to you.

     

  • DaveConnors Profile Picture
    34 on at

    Ok, thanks.

    I think what you say is certainly possible given my understanding of the original data

    Is there any solution? 

  • DaveConnors Profile Picture
    34 on at

    @Pstork1 so in the schema I updated every instance of 'type: "object",' to 'type: ["object", "array"]," and this is now working.

     

    For some reason I was thinking of the overall payload as object or array, hadn't considered the actual items in it the payload. Thanks so much for the pointer.

  • yu1 Profile Picture
    2 on at

    i also same issue and could you more in detail how to fix it 

    thx 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard