how to parse huge (>50mb) JSON file - android

How to parse data >50mb .There is zip inside json file which is more than 50 mb.please help me to solve this problem i will get out of memory error while parsing.

You should use Gson or Jackson for this purpose. note.. I have no clue how but you would do great with a pointer.
Loading a 50 mb file all at once would be a problem to the device due to the following :
Large file ... Lots of time to load , affects the users expression towards your app if its public.
Parsing , a 50 mb json file is nothing but 50 mb of arrays . It might not be a good idea to parse it all at once. Note.. Make sure you google on ways to avoid garbage collection.
Now ,
Why Gson or Jackson ?
Well , normally if you would parse a json file it would load it all at once taking a lot of time as well as affecting the memory consumption.
With the help of these , you can load off only a few items in the json file at a time..this is called json streaming.
For example you can use it while loading a product list , loading off a few products into the list as you scroll .

Related

Json Object Size Limitation Android

i have one big question, please suggest me what is the maximum responded (Server response) json object recommended size for android device ?
I have json Object size is 15 mb approximately, Is it Good for Android Mobile for analysis ???
Ya its required small json object for analysis for performance issue ???
Its Not Better Solution to Get Response of !5 mb .
if You Done This Then So many Issue Ocure like OutofMemory
other is Like Long Execution Time
user inherit From your app cause of Long waiting delay
thats y my suggestion is that you have to use pagination or load more data and retrive very samll json

Phonegap json size limit

Does anyone know what the size limit is of a JSON file in PhoneGap 3.0?
I access an external JSON file to populate a carousel gallery. When the JSON file was like 20KB size everything worked perfect but when I tested with 200KB the app began to lag really bad and if I use a bigger file like 500KB, the app gives an alert than it's unable to access the file. I tried to access the file from the server and from direct file in the app... same result.
So did anyone experience a similar problem or does someone know if there is a better solution to this?
Maybe SQLite ? Or how about using MySQL on the server and only exporting the JSON for the necessary query?
This discussion might help you. What they are saying is to
break the data up into chunks
load each in, and save off to SQLite
Hope this is what you looking for. Cheers!

Json parsing strategy in Android

I have a large json file (~3.5 MB), with (~140) complex objects, and the max depth in the object graph is about 4-5. I use Gson to parse it, but it's really slow. I've tried some way to parse it (like mixed parsing or using stream to parse), but I couldn't increase performance.
I checked Memory Analizer, it kill memory (70-80%), if I only parse the base Id of the objects. While parsing there are 400-500k object in memory (mostly string and char).
Would be parsing more efficient if the object graph wouldn't be so deep? Do you have a good idea how could be better? I tried other libs too (like Jackson), but performance wasn't better.
I had some good performance boost by using Jackson - you should not load whole json into memory but use createJsonParser(Reader r). If it does not work for you then either try spliting data and use separate threads - it makes sense if CPU is not fully loaded by single threaded version. Otherwise try using JNI json parsing implementation.

Android: JSON or XML, caching

I'm working on a little Android project in java, I'm using the webapi of spotify to get me so data to play around with.
First thing I notice when visiting: https://developer.spotify.com/technologies/web-api/ is that a developer can choose to use xml or json.
What i would like to do is 'cache' my data so i can do the following:
read one value from the file, or construct an object based on different values
add the object created above to the lisviewadapter
update the listview with the updated adapter
iterate over previous steps until parsing of file is complete
I want to be as quick as possible for my users so that the ui gets updated while parsing and loading the data. For this I sketched 2 use-cases.
add items to the listview until done
show a X amount of items and show a load more button
What file type is more ideal to use for my problem? xml parsing or json parsing?
How can i do this parsing? which tools meet my requirements?
Which use-case seems better to use?
any tips if you have done something like this in the past?
any guidance is appreciated
I don't make any distinction between XML or JSON. To cache data you have two options. Either write the data to a file (will require reparsing of the file to extract the data (unless you create a new file of, for example, CSV data)) or write the required data to a database after parsing. As for updating ListView, that would be up to you based on the number of entries you have.
Android has both XML and JSON parsers built-in. You don't need GSON.
I'd recommend JSON because JSON uses less bandwitch for transfering and google has made an awesome json parser library called GSON.

Json read error?

Hi friends I am getting the value from webservice while json value .I am storing in stringBuffer . I am getting the lot of value from webservice .so I am getting out of memory error .can any body tell how to avoid that?
Thank you,
You can allocate the StringBuffer with more amount of size, or try to implement paging or lazy loading..
But, with a lot of value, I think it's not good to use JSon
Json is stored in memory and simply lot of data from server cause out of memory exception. Better idea is to download data in chunks and store in database.
To do it use Jackson library that support streaming data or JsonReader but it is only in Android 3.0.

Categories

Resources