XML vs JSON parsing in Android

Android JBridge

Android-JBridge project uses Android SDK to develop the Android client application. This application consists of several classes for each form known as Activity and a RestEasy class which contains methods to communicate with the RESTEasy web services which is running on the JBoss application server. Android client is running on the Android emulator and since it has its own loop back IP address (, we use a  IP address which resolves to the computer which we are running the emulator from, this can be done by using IP address. On the production environment, this IP address will be replaced with the servers IP address which runs the application and web services.
Android JBridge application

The server application consists of EJBs, Session beans and a REST web services which accept connections from RESTEasy class in the Android client. It also contains all possible methods such as Get for selecting data, Put for updating data, Post for inserting data and Delete for removing the data from the database.

This article also provides a comparison for XML vs JSON parsing time in the Android operating system. JSON datatype is being used for transferring data between the Android client and the REST web service which results smaller data size which reduces traffic between the Android client and web service as well. Android client converts request into the JSON format, connects to the REST web services using httpClient class and sends the request. REST web service connects to the session beans and sends the data and gets the result and convert it to the JSON data format and returns it to the Android client.

The data store in this project is the JBoss built-in hypersonic database and it is possible to replace it with another database such as MySQL if necessary. Deployment of the project has been explained and shown with screen images which demonstrate the application successful testing and running.

XML and JSON data parsing comparison

In this project I have demonstrated on how to use Android mobile devices to connect it to the RESTEasy web services. An implementation for different methods such as SELECT, UPDATE, INSERT and DELETE operations provided. The project has been deployed under the JBoss Application Server and JSON data type is being used. The Android-JBridge project successfully developed and deployed under JBoss application server with testing evidence which provided in the previous section.

For JSON and XML datatypes performance and size comparison in the Android, RestEasyTest class has been created which contains a test method and performs data size and parsing time comparison between these data types. For more accuracy, different number of test products added to the JBoss hypersonic database.

Comparison between JSON and XML in the Android-JBridge

# ofObjects Data Size (bytes) Loading time (milliseconds) Parsing time(milliseconds) Total delay(milliseconds)
JSON 5 2600 24 54 78
XML 5 3059 28 62 90
JSON 13 8059 27 75 102
XML 13 9046 33 70 103
JSON 500 306415 2526 3252 5778
XML 500 341627 3703 2099 5802
JSON 1300 806808 4121 14965 19086
XML 1300 899370 5349 11609 16958
JSON 2500 1550076 6138 31024 37162
XML 2500 1727738 6871 24504 31375

The comparison table displays faster parsing time by JSON for smaller data, however by increasing the data size XML performs a faster parsing. Loading time is faster for JSON and also data size for JSON is smaller.

According to the performed tests in this project, the time which it takes for the data to load and process is the delay time until the device can display results.

XML vs JSON comparison in Android

In production environments we do not load that much data at once and the REST web services will load partial of the data by taking page number and page size arguments and comparing the parsing time between JSON and XML, they are almost similar for smaller data sizes and since loading time for JSON is shorter, total delay time for the JSON on small data is less than XML data. For parsing large-scale data, XML is a lot faster than JSON in the Android emulator.

Android  JBridge is open source and its available to download at:


About majid

Software engineer, Web developer and IT graduate. Profile: View My Profile
This entry was posted in Mobile Programming, Scripts. Bookmark the permalink.