0

I always get an error from retrofit (gson):

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

But in my opinion my return is right. It worked on my local server, but as I uploaded to webspace I always get this :/ In the case below I sent a JSONObject in form of {"string":"test"} and the webservice just returns it (and the answer actually reaches the device, but retrofit throws the error above). The relevant Logs from Retrofit:

   ---> HTTP POST http://mywebserver.net/set_string.php
   Content-Type: application/json
   Content-Length: 19
   {"string":"test"}
   ---> END HTTP (19-byte body)
   <--- HTTP 200 http://mywebserver.net/set_string.php (351ms)
   HTTP/1.1 200 OK
   Connection: close
   Content-Length: 188
   Content-Type: application/json
   Date: Tue, 26 May 2015 12:11:40 GMT
   Server: Apache
   X-Android-Received-Millis: 1432642297627
   X-Android-Response-Source: NETWORK 200
   X-Android-Sent-Millis: 1432642297438
   X-Powered-By: PHP/5.2.17
   {"string":"test"}        
   <!-- Hosting24 Analytics Code -->
   <script type="text/javascript"
   src="http://stats.hosting24.com/count.php"></script>
   <!-- End Of Analytics Code -->
   <--- END HTTP (188-byte body)

Thanks for your help in advance!

  • Where does the `"foo":"bar"` come from if "I sent a JSONObject in form of {"string":"test"} and the webservice just returns it" ? What about the `script` balise that seems added by your host `Hosting24`. The response doesn't seem to be a valid `JSON` anymore – Michael Laffargue May 26 '15 at 12:45
  • This was just a testing string, I removed it but the error remains... – wannabe_progger May 26 '15 at 12:53
  • The webhoster is 000webhost, where can I see how the packets are manipulated? – wannabe_progger May 26 '15 at 13:01
  • Take a look here : http://stackoverflow.com/questions/2268868/webhoster-inserts-a-javascript-which-brokes-my-code-how-to-remove-it – Michael Laffargue May 26 '15 at 13:10

0 Answers0