I get a crash when getting a JSON string from our application server. We believe that when the record has quotation marks, additional escape files are added.

In android, how can I determine if I get such a string and how to fix it from Android?
Here is our current response line 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; }
In addition, logcat does not include the entire json line after the failure, so I do not see the actual line that causes the failure.
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);
source share