cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
amanverma
Frequent Visitor

Comma (") is replaced in JSON from backslash+Comma (\")

Hope you are keeping safe and healthy.

I am creating this flow where i need to post JSON body to and external API using HTTP connector. Below is the part of JSON body where i have problem and looks like.

 

 

 

"groups": ["group1@rmail.com","group2@rmail.com","group3@rmail.com","group4@rmail.com"]

 

 

 

The email addresses are coming from a multi-line text column from sharepoint list in comma separated format something like "group1@rmail.com","group2@rmail.com","group3@rmail.com","group4@rmail.com"

Problem is that the comma (") is getting converted to (\") when passed to the JSON body. something like below.

 

 

 "\"group1@rmail.com\",\"group2@rmail.com\",\"group3@rmail.com\", \"group4@rmail.com\""

 

 


I tried using the expression below but no help.

 

 

replace(triggerOutputs()?['body/DistributionLists'],'\"','"')

 

 


here is an screenshot of how the (") is replaced with (\")

 

amanverma_0-1618829936557.png

can you please advise what could be the possible fix for this?

 

Thank you!

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User
Super User

It's because the value you are working with is a string, not a JSON array. Although I suspect it was a JSON array to start with. But working with a string like you have, you could do something like this to turn it back into a JSON array:

2021-04-19_12-27-26.png

the expression in the compose 2 is:

split(replace(outputs('Compose'), '"', ''), ',')

Then the output comes out as:

[
  "group1@rmail.com",
  "group2@rmail.com",
  "group3@rmail.com",
  "group4@rmail.com"
]

Which is a proper JSON array. The other possibility is that you are passing your value within quotes, which means everything inside needs to be escaped.

View solution in original post

3 REPLIES 3
Paulie78
Super User
Super User

It's because the value you are working with is a string, not a JSON array. Although I suspect it was a JSON array to start with. But working with a string like you have, you could do something like this to turn it back into a JSON array:

2021-04-19_12-27-26.png

the expression in the compose 2 is:

split(replace(outputs('Compose'), '"', ''), ',')

Then the output comes out as:

[
  "group1@rmail.com",
  "group2@rmail.com",
  "group3@rmail.com",
  "group4@rmail.com"
]

Which is a proper JSON array. The other possibility is that you are passing your value within quotes, which means everything inside needs to be escaped.

View solution in original post

@Paulie78  thanks for a quick response.

That's what i was missing, worked perfectly.

Can you please elaborate what is the expression below doing?

split(replace(outputs('Compose'), '"', ''), ',')

 
Thank you very much

From the inside out...

Replace is removing the double quotes and replacing them with nothing. So at that point the string would look like:

group1@rmail.com,group2@rmail.com,group3@rmail.com,group4@rmail.com

split, then splits the string on a comma, the output of the split operation is a JSON array.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (2,942)