0

While testing a REST service i am getting a JSON parsing exception as given below.

[
    {
        "errorCode": "APEX_ERROR",
        "message": "System.JSONException: Unrecognized character escape ''' (code 39) at [line:10341, column:31]\n\n(System Code)\nClass.GSSRestResourceUpsertStagingCustMaster.doPost: line 7, column 1"
    }
]

The actual JSON string that i used in Postman client is,

  {
    "CustomerNo": "404884",
    "PartFunc": "",
    "SalesGroupNo": "",
    "AccountOwner": "",
    "SalesOffice No": "",
    "SalesOffice": "",
    "**CustomerName": "Gavin O'brien",**
    "StreetAddr": "",
    "City": "London",
    "PostCode": "AB123CD",
    "State": "",
    "Country": "GB",
    "Telephone": "123456",
    "Fax": "",
    "Email": "someemailaddress@yahoo.com",
    "SalesOrg": "",
    "DistrChannel": "",
    "Division": "",
    "Addre ss": "Some address"
  },

Any Suggestions please.

1
  • 2
    I bet it's coming from Mr. O'brien here: "CustomerName": "Gavin O'brien", Jun 13 '15 at 16:29
2

After you generate the JSON string, try using the String.unescapeEcmaScript() method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.