Skip to content

Latest commit

 

History

History
41 lines (34 loc) · 1.62 KB

File metadata and controls

41 lines (34 loc) · 1.62 KB

Android: JsonReader Example

This is an example of how to use Android's JsonReader class to read data from a JSON array and convert the JSON array of JSON objects to an ArrayList of Java objects.

The app downloads a JSON script from a server. The JSON-Script contains an array of persons with their name, profession and age. The app decodes this information and saves it as an ArrayList of Java objects of the class "Person". At the end the app displays all the data to the user using a textview (as you can see in the screenshot).

I wrote lots of comments in the code, so it should be easy to understand.

Important Files:

The JSON-Script:

{
  "user":[
    {
      "name":"John Doe",
      "profession":"Doctor",
      "age":27
    },
    {
      "name":"Mike Miller",
      "profession":"Musician",
      "age":40
    },
    {
      "name":"Bob Graham",
      "profession":"Programmer",
      "age":32
    }
  ]
}

The Result: