JSON Parsing Tutorials

JSON:- Java Script Object Notation


Whenever app needs to communicate with server side database we just need to create a web services which may be in php,java, etc and that web services returns a set of statements that may be JSON or XMl.

It is nothing less than a table data which is displayed in the form of JSON or XMl.

JSON is easy to understand compare to XMl.

Example:- This is a Contacts table which is already hosted in server.




















IdNamePhone
1Ritu9898098980
2Ruhi7979079790

Now to communicate with the above database we need to create a web service that returns a JSON like below.

[

{"name":"Ritu","Phone":"9898098980"},

{"name":"Ruhi","Phone":"7979079790"}

]

What is JSONObject and JSONArray?


' { '   This notation is JSONObject which refers to each individual row in a table. It contains key / value pair data. Key refers the column name and value refers to the data of single row of that column. The above example has two columns 'name' and 'phone' with their respective values.

' [ ' This notation is JSONArray which refers to collection of JSONObject's. The above example has two rows in a table i.e two JSONObject's separated with a comma.

 

JSON Parsing Using Retrofit

 

Comments