I am working on an Android app and getting JsonObject/JsonArray from the server. Converting the String to Json manually works ok.
I recently switched to Volley for server requests, and want to use JsonObjectRequest
/ JsonArrayRequest
(rather than just plain StringRequest) to get the json directly and not have to bother about converting the string first (that's what the Json Requests were made for, right?).
However, the code always ends up in onErrorResponse
with a ParseError saying that the String cannot be converted to a JsonObject / JsonArray
(even though syntax seems totally ok).
I have tried to eliminate potential "invisible" characters by converting the server response to UTF8 (as suggested here ) but doesn't appear to solve the problem either. Also, the iOS version does not seem to have any issues with the same responses (I know that the underlying parsing algorithm may be very different).
Of course, working with StringRequests
or making custom requests would do the job (as suggested in a few other stackoverflow discussions), but it just bugs me a lot that I cannot get Json Requests to work. Anyone had this problem as well? Would be great to hear about potential causes and solutions!