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 .
I am a beginner in android development. I am on developing a dictionary app. The problem is quite obvious. I don't want the whole JSON file to be downloaded. I just want to send a key(a word in this case) and get its value(the meaning of that word) from the remote JSON. Any help would be appreciated.
Modify your server to support this sort of request, such as supporting a particular URL to retrieve values for a given key.
I need to know the purpose of using JSON in android ?
Please anyone tell me in a simple way...
Thanks
The same reason you'd use it on any platform. JSON is a way of storing and expressing information. It uses attribute-value pairs in a hierarchical structure. In Android specifically, you may need to download some information from a database, which could be stored in JSON and then read by your app. Alternatively, you could store data locally in JSON but there are probably better and more efficient ways to do that if you're not sending data across a network.
https://en.wikipedia.org/wiki/JSON
JSON is very light weight, structured, easy to parse and much human readable. JSON is best alternative to XML when your android app needs to interchange data with your server
For example, you can get data Json if you work with database. Or if you work with some API's then you can get data in format Json.
For example an app could fetch data from a server. When using JSON to get the data, the traffic is quite small and the app can easily work with it.
For example you have a server with a database with recipes, and your app displays recipes, the app could ask the server for recipes, and it gets a JSON in return. for example:
{
name: 'Cookies'
ingredients: { 'Butter', 'Eggs', ... /* I don't know, I'm not a chef :D */
...
}
The app can then just read the properties and display them in a neat list ;)
JSON (JavaScript Object Notation) is a lightweight format that is used for data interchanging. It is also a subset of JavaScript's Object Notation (the way objects are built in JavaScript
Pls go through this link: http://www.copterlabs.com/blog/json-what-it-is-how-it-works-how-to-use-it/
JSON stands for JavaScript Object Notation
JSON is lightweight text-data interchange format
JSON is language independent *
JSON is "self-describing" and easy to understand
* JSON uses JavaScript syntax for describing data objects, but JSON is still language and platform independent. JSON parsers and JSON libraries exists for many different programming languages.
Using JSON in Android is not different than using it on any other platform. The main advantage of the format (in comparison to XML for example) is the small size of the data. This is very important for mobile devices due to the scarce resource those application use - i.e. your mobile app should be able to run with little memory usage, slow internet connection and so on.
Besides Android's framework has built-in tools for parsing / creating JSON objects. Thus it is both easy and efficient to use JSON rather than XML. If you have any project specific reason to prefer another data presentation format - don't worry. It is perfectly fine NOT to use JSON as long as some other format is more suitable for your project.
In short JSON is usually the right choice due to its small footprint and easy of use.
Is there any way to send a huge data encoded to a 64-based String? It throws a 'outofmemory' exception when converting the data to string.
Cheers,
Stone
Apparently you got beyond memory borders even before ksoap got involved. Your data is just too freaking big when converted into base64 string. if you can not reduce amount of data tranfered, you shall switch to some streaming technique - like writing base64 data to stream / socked without allocating string. Or slice up your data in manageable pieces.
Or rethink your service architecture
I have a project which requires the json objects to be saved in database and then based on the users action will display info.
I can get the json from the API using here:http://p-xr.com/android-tutorial-how-to-parse-read-json-data-into-a-android-listview/ but need help with parsing the following which is a part of json objects.
It really depends on your data structure and amount of entries. If amount is small and queries / sorting requirements are simple, you may just bypass database entirely and parse JSON with buil it (not so good solution in terman of memory consumption) or pull parser ( like GSON - small external dependency bu way better perfromance )
Another option would be just store JSON documents in database, and some fields from them as separate columns for querying and indexing.
If you like to have complex object hierarchy you will find that you are reimplementing
some ORM solution.