Hello, I am getting an MalformedJsonException when I am using retrofit2.
Here is my originally posted question:
http://stackoverflow.com/questions/35984898/retrofit2-0-gets-malformedjsonexception-while-the-json-seems-correct
since the stacktrace said:
com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
I am wondering how to set Lenient mode for json conveter?
What I have found in the following seems not valid for retrofit 2
http://stackoverflow.com/questions/27485346/malformedjsonexception-with-retrofit-api
Could you please help?
Gson gson = new GsonBuilder()
.setLenient()
.build();
// ...
.addConverterFactory(GsonConverterFactory.create(gson))
Thanks however it's create() not build()
Gson gson = new GsonBuilder()
.setLenient()
.create();
I had added this line
Gson gson = new GsonBuilder() .setLenient() .create(); but still gives me the same error.
You can follow this solution: https://readyandroid.wordpress.com/error-use-jsonreader-setlenienttrue-to-accept-malformed-json-at-line-1-column-1-path/
Still, this doesn't work for you then try to do change in your API at server end because something wrong happens there.
As for me my sign up API doesn't work and was giving this same error I was thinking might be I am sending image as a multipart request that's why it is not working but where my edit profile API was working so I was little surprise of this then I made a clone of my Edit Profile API and renamed it to sign up and do the whatever required changes for the parameters and it started working. I don't know what wrong was there. Might be server guy may know what is the real cause of this issue.
Most helpful comment