Thursday, September 15, 2011

My First JSON Web Service with Android

This is the first project I did using JSON. This web service accesses the Sri Lanka Railway Department JSON file for displaying routes on Android Device. It will retrieve the JSONObject parse it and assign it to a 2D String array and display in a ListView in Android Application.

Technologies Used:

  • JSONObject - This is how routes are saved in railway department json file
  • ListActvity - To display the route list
  • HttpGet and HttpResponse (To retrieve the file from url)



Friday, September 2, 2011

Introduction to JSON with Android


JSON (JavaScript Object Notation) is a light-weight data interchange format. JSON is easy for humans to read and write. It is also very easy to code with them and parse. JSON is also language independent.



An object is an un-ordered set of name/value pairs




An array is an ordered set of values

JSON With Android

Android includes a library called org.json. Developers can easily use this library to work with JSON. this package contains 4 main classes. 
  • JSONArray
  • JSONObject
  • JSONStringer
  • JSONTokener

Try the example appears at this link (http://www.vogella.de/articles/AndroidJSON/article.html) It gives you a good intro of how to use JSON with your mobile application. It is very straight forward and most important thing is you have nothing much to learn.