Create file JSON online - android

I have worked with parsing JSON and I want to create a JSON file online. Have the website support to create file JSON online?

There is a nice online JSON editor at http://www.jsoneditoronline.org/.
Please note that I had never heard of such tools before reading this question, because I usually never write JSON by hand except for a few special cases. JSON is meant before all as a language that can be easily generated and parsed by machines.
(The special case I mentionned are some configuration files, and using nicely formatted and commented JSON, because the compact notation is definitly not human-friendly.)

Related

Web Services extensible markup language

If i want connect extensible markup language web services with android application what can i do and what the difference if i use java-script object notation web services with android
IF you want to compare XML and JSON format ( what would be better with android). Please see some points here:
JSON is both more compact and (in my view) more readable - in transmission it can be "faster" simply because less data is transferred.
In parsing, it depends on your parser. A parser turning the code (be it JSON or XML) into a data structure (like a map) may benefit from the strict nature of XML (XML Schemas disambiguate the data structure nicely) - however in JSON the type of an item (String/Number/Nested JSON Object) can be inferred syntactically.
If you find performance to be an issue (I'm making this suggestion because these libs make you super productive), there are mechanisms in both to allow you finer grained control. I doubt you'll have problems with performance though.
I can think of to use XML over JSON is when your webservice responses are huge. JSON usually requires the entire response to arrive before you can start parsing.
You can reach more example about them on internet, and do some android test to see the performance as well.
Example of JSON parsing in Android you can find in this Restful_Webservice_Call_And_Get_And_Parse_JSON_Data-_Android.
Example of XML parsing in Android you can find in this XML_Parsing_Android.
Hopefully, it would be helpful for you!

Why JSON Parsing in Android

I cannot find any explanation about why we use JSON when parsing it in Android?. Are we required to use it or is this just optional? What's the advantage and disadvantage of using it to extract data from the internet? Do we have to encode every data from PHP & MySQL into a JSON Format?
See this question. JSON is known as JavaScript Object Notation, it's a lot easier to parse then XML data, and there are libraries to help you retrieve the values from a JSON structure. As for the PHP & MySQL question, Android doesn't use MySQL, it uses SQLite instead. Hope this helps.
JSON is just a format to represent Objects in textform. Its used often in Android because its nice to work with and has many libraries to help parse it.
Sometimes other formats are used like XML or something else to represent the data.
You can use any communication protocol you want, json is just an accepted standard. You can't just 'dump the mysql database' to the app, there has to be some sort of communication protocol that the server and client agree on to transport the data.
Some alternatives are xml or a binary format (such as protobuf).
I'd recommend json due to the abundance of tools and literature on it.
(Heres a blog post I wrote on using Jackson to parse json in Android http://shmuelrosansky.com/jackson/android/2015/07/20/jackson-android/)

what is the purpose of using JSON in android?

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.

How to parse Microsoft Dto Url into Android and display as ListView

I am trying to use Jackson XML from Github and parse the following Microsoft DTO Url into a ListView within Android:
http://94d5d2ca8b8347c19478bfaaf058ac65.cloudapp.net/api/landingpage/00000000-0000-0000-0000-000000000000
To get:
Title
ImageUrl
Snippet
FeedSource -> name
Do I first parse in as XML, or can I force the response from request to be as JSON? Also tried reading Gson and looked at Windows Azure cloud (where this URL came from) but couldnt see any examples.
As I say in the comment, Gson can only parse JSON (not XML!), so it makes no sense to use it if you want to parse an XML file like the one you have... (in fact I'll retag your post). It makes even less sense to convert XML to JSON as you pointed out in your comment...
Since you have a XML file, what you need to do is to parse the XML data into Java classes, and in order to do that you need a XML Parser. In Android, they recommend to use the parser XmlPullParser. There is very complete documentation, including many step-by-step examples in Andoid Developers site.
Note that although they recommend that parser from Android, you can use other XML parsers, for example you can just use the DOM parser, which is perhaps the most basic one and you don't need any external library, like in this example. In fact in this last example they precisely build a ListView from a XML file as you're trying to do...

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.

Categories

Resources