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 / Compile JSON from the ...
Power Automate
Unanswered

Compile JSON from the content of an array variable

(0) ShareShare
ReportReport
Posted on by 9

Hi, I need the choices in an adaptive card (in Teams) to be dynamic, taken from a person field in a SharePoint document library.

 

Once I have retrieved the item properties I am appending the details I need, formatted as a block of JSON, to an array variable within an 'Apply to each' action. After the action completes I need to create a single continuous block of JSON from the array variable content for use in my adaptive card JSON.

 

The append to the array variable appears to work as needed, formatting the data as a single option block of JSON.

 

Jon_m_Lake_0-1715267926652.png

However, outside of the 'Apply to each' action, when I use a simple Compose action in an attempt to create a single continuous block of JSON, I get straight brackets at each end and all line breaks and spaces have been replaced with '\n\', or a combination.

Jon_m_Lake_1-1715268083039.png

I tried using the compose in my adaptive card JSON but it fails to be recognised as correct syntax JSON and so no options are presented in the card.

 

How can I create a single, correctly formatted JSON block from multiple items from a list?

 

Categories:
I have the same question (0)
  • Verified answer
    Jon_m_Lake Profile Picture
    9 on at

    Hi, I resolved my problem.

     

    The trick was to convert the array variable content into a string (using the 'string' expression) and then use a series of replace actions to remove the special characters. I created a 'new line' variable to inject a new line, replacing certain special characters that had been injected during the creation of the array.

     

    In the end the compose action expressions looks like this:

    replace(replace(replace(replace(replace(replace(string(variables('var_first_stage_reviewers')),'\n\',variables('var_new_line')),'\n',variables('var_new_line')),'\',''),'","',variables('var_new_line')),'["',''),'"]','')
     
    It may seem messy but it nicely produces perfectly formatted JSON options for use in my Teams adaptive card.

     

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 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard