I am getting a crash on receiving a JSON string from our applications server. We believe that when an entry has "quotes", there are extra escapes added.
In android, how can I determine if I receive such a string , and how do I fix it from the Android side?
Here is our current response string processing:
public String processResponseString(String responseString) {
if (responseString.startsWith("\"")) {
responseString = responseString.substring(1, responseString.length());
}
if (responseString.endsWith("\"")) {
responseString = responseString.substring(0, responseString.length() - 1);
}
responseString = EscapeUtil.unescapeString(responseString);
return responseString;
}
Also, logcat does not include the entire json string after the crash, so I cannot see the actual string that is causing the crash.
Exception
java.lang.ClassCastException: com.optiisolutions.housekeeping.model.OptiiAPI.OptiiError cannot be cast to java.util.Map
at com.optiisolutions.housekeeping.network.OptiiHTTPClientRetroFit$2.success(OptiiHTTPClientRetroFit.java:186)
at retrofit.CallbackRunnable$1.run(CallbackRunnable.java:45)
OptiiHTTPClientRetroFit.java:186
optiiClient.postRequest(event.getRequest(), new Callback<Map<String, Object>>() {
@Override
public void success(Map<String, Object> stringObjectMap, Response response) {
Log.d(TAG, "Successful response: " + stringObjectMap.toString());
String result = (String) stringObjectMap.get(OPTII_RESULT_TYPE);
String json = gson.toJson(stringObjectMap, Map.class);