• grahamH
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi All,

I'm having an issue here with properly escaping a backslash in JSON.
I'm using System.JSON.deserialize() to parse some JSON and I have a value that is something like this

{"First Name" : "John \photographer"}

I realize the backslash needs to be escaped so I try changing the string to contain {"First Name" : "John \\photographer"} but when I try to deserialize this I get the following error

Unrecognized character escape 'p' (code 112) at [line:1, column:291]

To me this doesn't make any sense.  The first backslash should be escaping the second backslash and so there should not be any confusion with the "p" character.  

So far the only way I can get the deserialize method to run properly is by changing the string to be {"First Name" : "John \\\\photographer"}.  However as you would expect this yeilds the result "John \\photographer" as the value when it is displayed in the package which is not what I want.

Any help here?
Hi All,

I'm having an issue here with properly escaping a backslash in JSON.
I'm using System.JSON.deserialize() to parse some JSON and I have a value that is something like this

{"First Name" : "John \photographer"}

I realize the backslash needs to be escaped so I try changing the string to contain {"First Name" : "John \\photographer"} but when I try to deserialize this I get the following error

Unrecognized character escape 'p' (code 112) at [line:1, column:291]

To me this doesn't make any sense.  The first backslash should be escaping the second backslash and so there should not be any confusion with the "p" character.  

So far the only way I can get the deserialize method to run properly is by changing the string to be {"First Name" : "John \\\\photographer"}.  However as you would expect this yeilds the result "John \\photographer" as the value when it is displayed in the package which is not what I want.

Any help here?