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 / How to parse string wi...
Power Automate
Unanswered

How to parse string with a \r from JSON

(0) ShareShare
ReportReport
Posted on by 48

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.

 

jimmart_0-1654588714476.png

 

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

 

Other fields work fine.

 

jimmart_1-1654588798670.png

 

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?

 

 

Categories:
I have the same question (0)
  • Paulie78 Profile Picture
    8,422 Moderator on at

    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. 

  • jimmart Profile Picture
    48 on at

    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

  • Paulie78 Profile Picture
    8,422 Moderator on at

    Sure, take the following example:

    CleanJSON.jpg

    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?

     

    Blog: tachytelic.net

    YouTube: https://www.youtube.com/c/PaulieM/videos

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

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

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard