Properties Methods Events Config Options Direct Link
Reader
  JsonReader

Class Ext.data.JsonReader

Package:Ext.data
Defined In:JsonReader.js
Class:JsonReader
Subclasses:ArrayReader
Extends:Reader

Data reader class to create an Array of Ext.data.Model objects from a JSON packet based on mappings in a provided Ext.data.Model constructor.

Example code:

var myReader = new Ext.data.Store({
    proxy: {
        type: 'ajax',
        reader: {
            type: 'json',
            // metadata configuration options:
            idProperty: 'id'
            root: 'rows',
            totalProperty: 'results'
        }
    },

    // the fields config option will internally create an Ext.data.Model
    // constructor that provides mapping for reading the record data objects
    fields: [
        // map Record's 'firstname' field to data object's key of same name
        {name: 'name'},
        // map Record's 'job' field to data object's 'occupation' key
        {name: 'job', mapping: 'occupation'}
    ],
});

This would consume a JSON data object of the form:

{
    results: 2000, // Reader's configured totalProperty
    rows: [        // Reader's configured root
        // record data objects:
        { id: 1, firstname: 'Bill', occupation: 'Gardener' },
        { id: 2, firstname: 'Ben' , occupation: 'Horticulturalist' },
        ...
    ]
}

Config Options

Config OptionsDefined By
 idProperty : String
Name of the property within a row object that contains a record identifier value. Defaults to id
Reader

Public Properties

PropertyDefined By
 jsonData : Mixed
DEPRECATED - will be removed in Ext JS 5.0. This is just a copy of this.rawData - use that instead
JsonReader
 rawData : Mixed
The raw data object that was last passed to readRecords. Stored for further processing if needed
Reader

Public Methods

MethodDefined By

Public Events

This class has no public events.