org.json.JSONException: Value okhttp3.internal.http.RealResponseBody@da68fa1 of type java.lang.String cannot be converted to JSONObject

okhttp request data is then parsed by the data json, found in the log warn:


The reason this error is because the json parse error.
First, I confirm that I parse error codes, find the source was found to be a problem with json data returned.

ResponseBody data=response.body();
String json=data.toString();
processData(json);

The above data.toString should be changed data.string ().
the reason:

data.toString returns json objects, data.string () is the json data returned.

Figure:
data.toString return data

data.string () returns the data

Guess you like

Origin www.cnblogs.com/dearnotes/p/12230891.html