I am getting an error when I am trying to parse a JSON response from authorised.net.

System.JSONException: Unexpected character ('' (code 65279 / 0xfeff)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at input location [1,2]


    "customerPaymentProfileIdList": [],
    "customerShippingAddressIdList": [],
    "validationDirectResponseList": ["1,1,1,(TESTMODE) This transaction has been approved.,000000,P,0,none,Test transaction for ValidateCustomerPaymentProfile.,1.00,CC,auth_only,,RAMESH,TEST,,TEST TEST,test,CA,2222,,,,test123@gmail.com,,,,,,,,,0.00,0.00,0.00,FALSE,none,BF4D71FADF17DA79C3B33ED0D2BA8438,,,,,,,,,,,,,XXXX0015,MasterCard,,,,,,,,,,,,,,,,,"],
    "messages": {
        "resultCode": "Error",
        "message": [{
            "code": "E00039",
            "text": "A duplicate record with ID 1810594140 already exists."

I have tried to parse this JSON by using create parser method.

JSONParser validationparser = JSON.createParser(res.getBody());   
while (validationparser.nextToken() != null) {

I also try to parse the same JSON by creating a JSON parser in apex class. But still getting the same error. Tried to change the Version from 39 to 30 but nothing worked.

public class JSON2Apex {

public class Messages {
    public String resultCode;
    public List<Message> message;

public class Message {
    public String code;
    public String text;

public List<CustomerPaymentProfileIdList> customerPaymentProfileIdList;
public List<CustomerPaymentProfileIdList> customerShippingAddressIdList;
public List<String> validationDirectResponseList;
public Messages messages;

public class CustomerPaymentProfileIdList {

public static JSON2Apex parse(String json) {
    return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);


Do anyone have any idea to resolve this issue. I totally get stuck with this. Thanks in advance.

  • I'm having this same issue. Authorize.net?
    – Tyler Zika
    Apr 29 '18 at 0:04

The character 65279 is the Unicode Character 'ZERO WIDTH NO-BREAK SPACE'. As this displays as nothing, when pasted into code it can't be seen but is present.

If you are seeing this error in a test case, then I suggest running the JSON text used by the test case through e.g. https://www.textmagic.com/free-tools/unicode-detector and eliminating that/those characters.

If the text is coming directly from an external service, then flag the problem with the service provider.


I know this is a bit old, but I was running into the same error. From what I've seen in the past, the service in question seems to be Authorize.net.

The following seems to work for me. The trim() might be overkill, but it might not.

HttpRequest request = createJsonRequest();
HttpResponse response = (new Http()).send(request);
if (response.getStatusCode() != 200)
   // handle errors

String responseText = response.getBody();
if (responseText  != null)
  responseText = responseText.trim().replace('\uFEFF', '');
  return (Map<String, Object>)JSON.deserializeUntyped( responseText );

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