Search code examples
jsonazureparsingazure-logic-apps

LogicApps : ParseJson component fails because of \ (backslash)


As the title says, I am trying to parse a json request inside an azure logic apps workflow with the parse json component : enter image description here

The problem is that one of the field inside the request contains a "\" (backslash) :

{
"user":"bbbbbb\aaaaaa"
}

This leads to the following error when trying to parse the json :

The 'content' property of actions of type 'ParseJson' must be valid JSON. The provided value cannot be parsed: 'Bad JSON escape sequence: \a. Path 'user', ...'.

But when I try to escape the backslash with another backslash like this : "\\", I end up with a successful parsing but with two backslash which is wrong. I want my variable to contain the original value with only one backslash, which is the correct one.

How can I achieve this ? I understand that a json property value containing a single \ is incorrect and must be escaped. But when I escape it, I need to get the original value after parsing and not the escaped value.

Thank you, Guillaume


Solution

  • Having 2 backslashes is not wrong. This is in fact only one character (1 escaped backslash), you only see it as 2.

    If you check the length of the following user value from the code, you will see that it will be 13 and not 14.

    {
      "user": "bbbbbb\\aaaaaa"
    }