| Data reader class to create an Array of Ext.data.Record objects from a JSON response
based on mappings in a provided Ext.data.Record constructor.
Example code:
RecordDef recordDef = new RecordDef(new FieldDef[]{
new StringFieldDef("name", "name"), // "mapping" property not needed if it's the same as "name"
new StringFieldDef("occupation") // this field will use "occupation" as the mapping.
});
JsonReader reader = new JsonReader(new JsonReaderConfig() {
{
setTotalProperty("results"); // The property which contains the total dataset size (optional)
setRoot("rows"); // The property which contains an Array of row objects
setId("id"); // The property within each row object that provides an ID for the record (optional)
}}, recordDef);
This would consume a JSON file like this:
{ 'results': 2, 'rows': [
{ 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
{ 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
}
|