Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use XML or JSON as a data format in Android Applications?

Tags:

json

android

xml

I'm starting to develop an application for Google Android and heavily relying on a web API that can deliver data in a restful way via json or xml. I now have to decide which library to choose.

I saw that google includes org.json classes in the API but haven't tested them yet.

How are your experiences? What library/API should I use and why?

like image 566
Janusz Avatar asked Feb 23 '10 09:02

Janusz


People also ask

Is it better to use JSON or XML?

JSON is best for simple applications, developed to satisfy simple requirements surrounding data interchange. XML is best for applications with complex requirements surrounding data interchange, such as in enterprise.

When would you use JSON over XML?

One of the most significant advantages of using JSON is that the file size is smaller; thus, transferring data is faster than XML. Moreover, since JSON is compact and very easy to read, the files look cleaner and more organized without empty tags and data.

Is JSON used in mobile application?

Android JSONObject is used for JSON parsing in android apps. In this tutorial we'll discuss and implement a JSONObject in our android application to parse JSON data. JSON stands for JavaScript Object Notation.


1 Answers

If you're mostly aiming for an internal API that is simply a link between servers you control and a client you're creating, I'd highly recommend JSON - it's far more concise in most cases, thus minimizing the data transfer necessary.

Parsing JSON with org.json is as straightforward as passing the JSON string to the constructor of JSONObject, and then using the appropriate type get-methods on each of your expected attributes.

like image 192
Amber Avatar answered Oct 16 '22 08:10

Amber