Search code examples
jsonextjsextjs3jsonreader

How to read non-iterable parameters with ExtJS JSONReader


I am sending over the following JSON structure:

{ "header": "Staff Name",
  "result":[
    {"firstname":"Leo","id":1,"lastname":"name"},
{"firstname":"Robert","id":2,"lastname":"name"}],
  "totalCount":4,
  "success":true}

In my JS file I define the JSONReader as follows:

var resultReader = new Ext.data.JsonReader({
    root:'result',
    totalProperty: 'totalCount'                 
}, Ext.data.Record.create([                           
    {name: 'id'} ,
    {name: 'firstname'},
    {name: 'lastname'}
]));

This works and I am able to iterate over the result-array. However what I want to achieve is to somehow be able to read the parameter "header" found in the beginning of the structure.

How should I define the JSONReader to store this parameter, and how can I later load this parameter?


Solution

  • It should be available at resultReader.jsonData.header