Showing results for 
Search instead for 
Did you mean: 
Helper II
Helper II

How to parse string with a \r from JSON

Hi Guys,


Has anyone tried to parse a string from JSON that has a "\r" on it? I am trying to get that parsed however it doesnt show up, others without a "\r" parses correctly. Here is the exact Parse value.




And when I try to get the value from it, it comes up as blank.


Other fields work fine.




The expression I am using to get the value for each of those fields would be "items('Apply_to_each')?['SerialNo'] also have tried using ['SerialNo\r] and ['SerialNo%0D" without the quotes. This works for other fields such as so_seqno and orderid (items('Apply_to_each')?['orderid'],


The original format before being parsed to JSON is csv.


Does anyone have any idea on how I could get the value for that specific field?



Super User
Super User

I think I would convert the JSON to a string (with the string function) replace the \r with nothing and the convert it back to a JSON with the JSON function. 

Hi @Paulie78 ,


Thanks for the input however im not really sure how to do that? Can you give a short sample if possible? Thanks again

Sure, take the following example:


The first compose action is just a container for example JSON, which is:

	"Country": "United Kingdom",
	"SerialNo\r": "\"215211291266\"\r"

The action Compose 2 removes only the \r elements and produces output like this:

  "Country": "United Kingdom",
  "SerialNo": "\"215211291266\""

The code for Compose 2 is:

json(replace(string(outputs('Compose')), '\r', ''))

The action Compose 3 removes both the \r and the escaped quote characters you have in your JSON and produces the output:

  "Country": "United Kingdom",
  "SerialNo": "215211291266"

The code for Compose 3 is:

json(replace(replace(string(outputs('Compose')), '\r', ''), '\"', ''))

In both cases, the JSON is first converted to a string with the string function, then replace is used to remove the elements which are to be removed. Then it is converted back to JSON format with the json expression.


Does that help?




If I answered your question, please accept it as a solution 😘

Helpful resources

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

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.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (2,044)