Skip to content Skip to sidebar Skip to footer

Out Of Memory Exception While Parsing 5mb Json Response In Android

I am getting 5MB of a JSON response, I am downloading and saving in StringBuffer using a byte array with 1024 size. To parse this response, I have to create a JSONObject with the p

Solution 1:

You need to use a Stream-based parser. in API 11+ there is http://developer.android.com/reference/android/util/JsonReader.html

Below, there is gson http://code.google.com/p/google-gson/

Also, you probably need to save your service response as a file before reopening it with the JsonReader.

Solution 2:

Use Jackson

Jackson Github

That should solve your issue. But i will not recomment you to use huge data without pagination.

Post a Comment for "Out Of Memory Exception While Parsing 5mb Json Response In Android"