What is better in terms of parsing performance in Android, XML or JSON?

I am new to Android development.

What should I use for my Android, XML or JSON application?

Which is better in terms of parsing performance?

I would appreciate any sample code.

+8
json android xml-parsing
source share
5 answers

JSON is best compared to XML

XML is not well suited for data exchange

Simplicity

XML is simpler than SGML, but JSON is much simpler than XML. JSON has a much smaller grammar and more directly displays the data structures used in modern programming languages.

extensibility

JSON is not extensible because it is not necessary. JSON is not a document markup language, so there is no need to define new tags or attributes to represent data in it.

Interoperability

JSON has the same interoperability as XML.

Openness

JSON is at least as open as XML, perhaps more so because it is not at the center of the battle against corporate / political standardization.

Weight: Since JSON syntax requires fewer characters, it is lighter on the explorer than XML.

But still it depends on the requirements!

+23
source share

A few questions about something like this have been asked before: Which is better: Json or XML (PHP) They explain what is faster and what is not.

You can always use Google GSON , which makes JSON parsing (no matter how large the dataset) very fast. I personally prefer JSON over XML, as it is easier to exchange data, even if readability is difficult.

+7
source share

Based on experience, XML parsing can be bothersome on Android 2.1 and earlier due to an error that breaks encoded objects into separate tags (http://code.google.com/p/android/issues/detail?id=2607 )

Personally, I think JSON analysis is more convenient. Take a look at the following link: http://www.technotalkative.com/android-json-parsing/

+2
source share

JSON is better than XML if the data size is not too large. Thus, a GSON developed using the JSON api is better because it is easy to handle. But JSON has one main drawback, that is, the data is loaded into memory and then analyzed. If the data size is too large, it will be thrown through an exception. In this case, XML is very useful. JSON is better because it is faster than XML (since hashing is used)

+1
source share

The only advantage of XML is that it is more "human readable" ... but, seeing that the end user will not read XML, there is no need to use it.

JSON is much easier / faster to parse than XML

+1
source share

All Articles