Home

Published

- 1 min read

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

img of com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON

The solution for this is noted below

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

Solution

   Gson gson = new GsonBuilder()
        .setLenient()
        .create();

Retrofit retrofit = new Retrofit.Builder()
        .baseUrl(BASE_URL)
        .client(client)
        .addConverterFactory(GsonConverterFactory.create(gson))
        .build();

Try other methods by searching on the site. That is if this doesn’t work