cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
in2217
Resolver I
Resolver I

Passing HTML content as a variable to build a JSON

Dear community, I'm trying to pass a rich text content, effectively HTML text, between flows. First flow gets the content as a formatted text, puts it into a variable and then uses this variable to build a JSON that is then POSTed to another flow via HTTP call. The pseudo code would look like this: set varMyRichText = links > set varMyJSON = { "RichTextVar" : "variables('varMyRichText')"} Now when I look at the content of the varMyJSON it gets all confused because it messes up the quotes found inside original rich text like those that are part of hyperlinks, with the quotes that come around "value" in the JSON. I could probably map all the special chars to their ascii codes in an set of extra steps, but is there any better way to just pass the "rich text" content around? Thank you,

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

update with solution here.

 

Looking closer at what causes the problem, I found that it was only double quote sign ( " ) that ruined JSON as it would collide with the quotes in the syntax of the JSON:

{

"key" : "$value"

}

 

So I've run the value through "replace" function before adding it to the JSON. Like this:

 

replace(variables('value'), '"', '"')

 

(ASCII code for double quote is ")

 

This was it.

No need to translate it back on receiving end.

 

I'll remember to translate the double quotes in the rich text / html texts whenever I'll need to pass it over to another flow or otherwise use it inside a JSON.

View solution in original post

3 REPLIES 3
v-litu-msft
Community Support
Community Support

Hi @in2217

 

You can store these HTML text stored as an HTML file in a SharePoint folder, then store the link into the JSON object.

There is a document about the portable text, I hope it can help you:

https://github.com/portabletext/portabletext

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-litu-msft,

 

 

 

 

 

Hi,

update with solution here.

 

Looking closer at what causes the problem, I found that it was only double quote sign ( " ) that ruined JSON as it would collide with the quotes in the syntax of the JSON:

{

"key" : "$value"

}

 

So I've run the value through "replace" function before adding it to the JSON. Like this:

 

replace(variables('value'), '"', '"')

 

(ASCII code for double quote is ")

 

This was it.

No need to translate it back on receiving end.

 

I'll remember to translate the double quotes in the rich text / html texts whenever I'll need to pass it over to another flow or otherwise use it inside a JSON.

Helpful resources

Announcements
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.

New Process Advisor Capabilities carousel.png

Read the blog for the latest news

Read the latest about new experiences and capabilities in the Power Automate product blog.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

AI Builder AMA June 7th carousel (up on May 25th, take down June 8th) (1).png

'Ask Microsoft Anything' about AI Builder!

The AI Builder team invite you to ask questions and provide helpful answers at our next AMA.

Users online (1,457)