View Full Version : Mapping complex object with array in JsonReader

5 Mar 2010, 7:14 AM
Helo everyone,

I need to map this json object in a JsonReader:

{"paciente":{"categorias":[{"nombre":"Diabetico","id":1},{"nombre":"Bulimico","id":2}],"fechaActualizacion":"03/03/2010" ,direccionComercial":{"comuna":{}}}

I have this in an JsonFormPanel:

url: 'seam/resource/rest/pacientesvc/actualizar',
reader: new Ext.data.JsonReader({
root: 'paciente',
fields: [
{name: 'fechaActualizacion', type:'string'},

The question is : How must it be the mapping for array "categorias" ?

Thanks in advance.

Mike Robinson
5 Mar 2010, 8:01 AM
I do not expect that JSONReader would know how to handle this one-to-many relationship. (Uno paciente tenga uno o mas categorias...)

You might need to write your own AJAX-request handler that issues the request, loops through the structure that is returned, and adds its records to the appropriate (local...) Stores. In other words, you are not using JSONReader: you're issuing your own call, then populating local ArrayStores.

Any way that you do it, make it abundantly clear, and simple, and well-documented.