I'm currently making a callout to a 3rd party vendor and I'm getting a huge response. What is currently messing me up is this section:
"MessageSeq":13,"Description":"config file: config-qa1.txt\"","MessageTS":"2014-02-17T14:46:58","MessageLevel":4,"IsSystemMessage":false
As you can see here, the portion at the end of the Description value is ended with backslash double quote. If I attempt to parse this via the JSONParser I get an exception. Does anyone have an recommendations on how to resolve this?
Exception Message:
System.JSONException: Unexpected character ('"' (code 34)): was expecting comma to separate OBJECT entries at [line:1, column:3699]
Updated with sample Code
public class ResponseWrapper{
// fields from JSON to auto map
public Integer messageSeq;
public String Description;
public String messageTS;
public Integer messageLevel;
public Boolean isSystemMessage;
// parsing fields
private ResponseWrapper theResponse;
private JSONParser parser;
public void parse(String jsonString){
parser = JSON.createParser(jsonString);
parseJSON();
}
private void parseJSON(){
while (parser.nextToken() != null) {
if (parser.getCurrentToken() == JSONToken.START_OBJECT) {
theResponse = (ResponseWrapper)parser.readValueAs(ResponseWrapper.class);
}
}
}
}
String responseString = '{"MessageSeq":13,"Description":"config file: config-qa1.txt\"","MessageTS":"2014-02-17T14:46:58","MessageLevel":4,"IsSystemMessage":false}';
system.debug('\n\nBEFORE\n' + responseString);
//****Place code in here to test such as ReplaceALL***
ResponseWrapper parser = new ResponseWrapper();
parser.parse(responseString);