Skip to main content

Notifications

Community site session details

Community site session details

Session Id : Fs7uROzKezAAcb8nqj5gJU
Power Automate - Building Flows
Answered

Converting String to JSON Object

Like (0) ShareShare
ReportReport
Posted on 19 Apr 2021 21:45:58 by 172

Hi There,

 

I have a child flow that produces a string value based on the outcome of a loop that checks for data consistency across multiple tables and returns that string looking a bit like this :

 

{ "type": "ColumnSet", "columns": [ { "type": "Column", "items": [ { "type": "TextBlock", "text": "C0007 / AoG", "weight": "Bolder" } ], "width": "135px" }, { "type": "Column", "items": [ { "type": "TextBlock", "text": "Was : " } ], "width": "80px", "spacing": "none" }, { "type": "Column", "items": [ { "type": "TextBlock", "text": "" } ], "width": "stretch", "spacing": "none" }, { "type": "Column", "items": [ { "type": "TextBlock", "text": "Now : " } ], "width": "80px" }, { "type": "Column", "items": [ { "type": "TextBlock", "text": "", "width": "stretch" } ], "width": "stretch" } ] },{ "type": "ColumnSet", "columns": [ { "type": "Column", "items": [ { "type": "TextBlock", "text": "Margin %", "weight": "Bolder" } ], "width": "135px" }, { "type": "Column", "items": [ { "type": "TextBlock", "text": "Was : " } ], "width": "80px", "spacing": "none" }, { "type": "Column", "items": [ { "type": "TextBlock", "text": "9.45" } ], "width": "stretch", "spacing": "none" }, { "type": "Column", "items": [ { "type": "TextBlock", "text": "Now : " } ], "width": "80px" }, { "type": "Column", "items": [ { "type": "TextBlock", "text": "9.4526422537", "width": "stretch" } ], "width": "stretch" } ] }

 

As you can see, this is essentially a JSON object that I want to then inject into an Adaptive Card (Teams), but Power Automate doesn't like Strings for this (complains that it's not JSON), so I've been using the json() expression to convert the string to a JSON object. So far so good. The challenge now is that when I do this (the json() expression) - only the first JSON 'node' is returned, so this bit :

 

{ "type": "ColumnSet", "columns": [ { "type": "Column", "items": [ { "type": "TextBlock", "text": "C0007 / AoG", "weight": "Bolder" } ], "width": "135px" }, { "type": "Column", "items": [ { "type": "TextBlock", "text": "Was : " } ], "width": "80px", "spacing": "none" }, { "type": "Column", "items": [ { "type": "TextBlock", "text": "" } ], "width": "stretch", "spacing": "none" }, { "type": "Column", "items": [ { "type": "TextBlock", "text": "Now : " } ], "width": "80px" }, { "type": "Column", "items": [ { "type": "TextBlock", "text": "", "width": "stretch" } ], "width": "stretch" } ] },{ "type": "ColumnSet", "columns": [ { "type": "Column", "items": [ { "type": "TextBlock", "text": "Margin %", "weight": "Bolder" } ], "width": "135px" }, { "type": "Column", "items": [ { "type": "TextBlock", "text": "Was : " } ], "width": "80px", "spacing": "none" }, { "type": "Column", "items": [ { "type": "TextBlock", "text": "9.45" } ], "width": "stretch", "spacing": "none" }, { "type": "Column", "items": [ { "type": "TextBlock", "text": "Now : " } ], "width": "80px" }, { "type": "Column", "items": [ { "type": "TextBlock", "text": "9.4526422537", "width": "stretch" } ], "width": "stretch" } ] }

 

The rest appears to be discarded. Is there a way I can get Power Automate to convert the whole JSON object (or objects), or is there maybe a different solution anyone can point me at for this?

 

Thanks in advance!

  • Serviced2000 Profile Picture
    172 on 19 Apr 2021 at 22:35:39
    Re: Converting String to JSON Object

    Hi Max,

     

    I think I'll add JSONLint to my bookmarks! You were 100% correct - the object was poorly formed. I was heading down a similar line of thought but just couldn't see the break.

     

    Thanks!

  • Verified answer
    henkenTech Profile Picture
    135 on 19 Apr 2021 at 22:09:21
    Re: Converting String to JSON Object

    Hey there,

     

    the reason it does not work is that the JSON object is malformed and actually ends there. You can test this by putting it into a JSON list: JSONLint - The JSON Validator

     

    If the object is formed correctly, this should not occur.

     

    Hope this helps,

     

    Max

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Automate - Building Flows

#1
David_MA Profile Picture

David_MA 222 Super User 2025 Season 1

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 215 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 190

Overall leaderboard
Loading started