Lab 7
Lab 7
Mobile Computing
Lab 7
1 JSON
• This weeks lab will the code from the last lab.
• Some modifications need to be made in order to process the messages that are returned from
the server.
• We need to process the JSON message that is returned from the server.
• Luckily Android provides classes to help, so we dont have to process the json string manually.
• The code above takes the JSON string and processes it as a JSON Array. Each item in the array
is then processed as a JSON object, with the properties of the object that we care about being
name and description.
• An example of how to use the class is shown below. In your case, you should use the string
returned from the server rather than a manually created string, and modify the processing code
to use the fields you care about rather than name and description.
String myJson="[{id: 1 , name : Pravesh , description : Java
Guy },{ id : 2 , name : Richard , description : C ++ Guy }]";
processJSON(myJson);
2 Practice
Try modifying your code to process the Cars that are returned from your PHP script from last week.
The code should display the license plate for each car on the screen, with one TextView created for
each car.