Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
Question :
What is this error ? how can i fix this ? my app run but cant load data . and this is my Error: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
Here is the solution
What is this error ? how can i fix this ? my app run but cant load data . and this is my Error: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
Here is the solution
Finally I solved my problem which is not related to the json lenient mode, something wrong with my POST response (there some other non json output before the json data).
Here is the response from JakeWharton regarding how to set Gson lenient mode:
make sure that you have:
compile 'com.google.code.gson:gson:2.6.1'
Gson gson = new GsonBuilder()
.setLenient()
.create();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.client(client)
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
If you add this to your retrofit Now it's gives you another error:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
Here is the solution of above issue:
Even without seeing your JSON string you can tell from the error message that it is not the correct structure to be parsed into your Ad class.
Gson is expecting your JSON string to begin with an object opening brace. e.g.
{
But the string you have passed to it starts with an open quotes
"
No comments :
Post a Comment