[Solved] com.google.gson.stream.MalformedJsonException:Use JsonReader.setLenient(true) to accept

The following error occurred while parsing with Gson.

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

 

Solution:

private final Gson mGson = new GsonBuilder()
.setLenient() // Set the non-strict mode of GSON setLenient()
.create();

private final Retrofit mRetrofit= new Retrofit.Builder()
.baseUrl(BaseUrl)
.client(mOkHttpClient)
.addConverterFactory(GsonConverterFactory.create(mGson))
.build();

Similar Posts: