Retrofit com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept

Error:

com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $

Reason: The original data returned by the interface does not correspond to the data format to be converted;

For example the problem I am getting wrong is as follows:

For example, if the interface reports an error and returns an Html, and Retrofit requests the interface method, the data should be parsed into data in the format of List<ResStoreList>;

 Solution:

1. If you just start debugging the interface, it means that the Android side and the server have not agreed on the data format returned by the interface; just unify the data format;

If the Android side cannot find the problem, you can change the data returned by the interface of the Retrofit receiving end into a ResponseBody object, so that no matter what data the interface returns, it can be parsed and no error will be reported, and then specific objects can be generated based on the data;

 2. If the interface is already in use, you need to confirm whether the data returned by the interface has changed; or whether the interface reports an error that causes Retrofit parsing errors;

Guess you like

Origin blog.csdn.net/ezconn/article/details/127497836