Java – Android – weird escapeutil.unescapestring crashes
•
Android
We encountered a crash when receiving JSON strings from our application server. We think that additional escape will be added when the entry has "quotation marks"
In Android, how do I determine whether I receive such a string and how to repair it from the Android side?
This 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;
}
In addition, after the crash, logcat does not contain the entire JSON string, so I can't see the actual string that caused 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
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码