Skip to main content

Notifications

Community site session details

Community site session details

Session Id : i79kfRvPwP1wGI6XlBrkFM
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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

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

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard
Loading started