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.

View solution in original post

Helpful resources

Announcements
Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,668)