I'm trying to access an API that respond with a JsonArray. The only tutorials I found was to parse the response of a JsonObject. I'm still trying to wrap-up my head around Android, I don't even understand how to call an external API.
If anybody got some tutorials or code example, I'd be really grateful !
Thanks in advance.
Add a comment
|
2 Answers
Comments
If the JSONArray is very large maybe a stream based solution is better since you don't have to keep the whole object in the memory. Therefore JsonReader could be more efficient.
3 Comments
Simon
Yeah, the json will be quite big, thanks for this, I'll watch this. Can you read JsonArray with it or just JsonObject ? Cause the exemple got an ending bracket, but no beginning one.
Stenes
I think this is a typo in the example, since it is not a valid Json with the messed up brackets. So if your root Json is an array (starts with []) create the Reader and use reader.beginArray(); like in the example else if it is an object (starts wit {}) use reader.beginObject();
Simon
Yeah, it seemed weird to me. Thanks a lot man, I'm gonna try that !