How to remove \r\n from this JSON

I want to store in the below format

Hi @shivkumar

=> Use Read Text File activity to read the file and store it in a variable say str_Text

=> Use below syntax in Assign:
str_Text = str_Text.Replace("\r\n", String.Empty)

This should replace \r\n from your file.

Regards

Already tried but getting ** this

image

Its a JOSN

JSON formatter intend i also tried

Hi @shivkumar

Can you share the text file. I will help you

Regards

Hi @shivkumar

instr.Replace("\r\n", "")

Input is in the text file and required output is in the messagebox.

Hope it helps!!

whenever we see ", \n … we should get cleared on what a base we do look at the json:

  • debugging panel - UiPath Studio
  • Textfile
    …
    So we can seperate what is a beautified view (e.g. " escaping) and what is real content

As we have seen:

we would interpret that the value of the CNB01506 Property is a serialized Object / JSON String

So we would at a first stage question it

  • is this intended?
    OR
  • is the JSON wrongly assembled

When the serialized JSON string Values was intended we would not remove the "\n\r …

What is the intention to remove the linebreaks from the serialized JSON?

1 Like

please can you try this

System.Text.RegularExpressions.Regex.Replace(yourtext, "\r\n", " ")

image

** not removed

Hi @shivkumar

Try this:

str_Text = str_Text.Replace("\r\n",String.Empty).Replace("\",String.Empty)
Input:

Output:

Check the output @shivkumar

Regards

1 Like

try this System.Text.RegularExpressions.Regex.Replace(yourtext, "\r\n|\\", "") or System.Text.RegularExpressions.Regex.Replace(yourtext, "\r\n|\", "")

thanks , Its working

Thanks for your help

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.