0

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?

aksamit
  • 2,325
  • 8
  • 28
  • 40

1 Answers1

1

It should be available at resultReader.jsonData.header

Mchl
  • 61,444
  • 9
  • 118
  • 120
  • Thanks, turns out to be very obvious now. The reason I didn't get it to work earlier was because the JSON data was not available at the moment when I tried to read it. – aksamit Aug 17 '11 at 10:45
  • Oh yes. The 'Asynchronous' part in 'AJAX' can be confusing. – Mchl Aug 17 '11 at 10:46