Converting incoming JSON data into models using JsonReader
As we saw earlier in the chapter, a reader helps us in data loading and converting the incoming data into a model, which can then be added to a store. Based on the type of data, Sencha Touch provides two readers – JsonReader
and XmlReader
. In this recipe we will see how to make use of the JsonReader
to read the JSON data and prepare a model out of it.
Getting ready
Make sure that you have set up your development environment by following the recipes outlined in Chapter 1.
How to do it...
Carry out the following steps:
- Create and open a new file named
users.json
and paste the following into it:{"users": [{ "id": "1", "name" : "Ajit Kumar", "age" : "32", "phone": "555-555-5555", "email": "ajit@walkingtree.in" ...
Get Sencha Touch Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.