PDA

View Full Version : Mapping "JSON" to meta object



flatburger
14 Oct 2007, 2:58 AM
i found this

JsonReader( Object meta, Object recordType )

in my side this mean:

1. meta will have a object
2. the recrd type is the field



reader : new Ext.data.JsonReader({
record : 'contact',
success: '@success'
}, [
{name: 'first', mapping:'name/first'}, // custom mapping
{name: 'last', mapping:'name/last'},
'company', 'email', 'state',
{name: 'dob', type:'date', dateFormat:'m/d/Y'} // custom data types
]),


but after i try to read this json



{
response:{
success:'true',
contact:{
name:{
first:'Jack',
last:'Slocum'
},
company:'Ext JS',
email:'support@extjs.com',
state:'OH',
dob:'04/15/2007'
}
}
}


and this one also



{
success:'true',
contact:{
name:{
first:'Jack',
last:'Slocum'
},
company:'Ext JS',
email:'support@extjs.com',
state:'OH',
dob:'04/15/2007'
}
}


both cannot work.

any idea how to map the json with the array? so i can use it in fieldset.

F

Animal
14 Oct 2007, 3:35 AM
Don't use a JsonReader. Just return the simple Json format as described in the docs and manual.

flatburger
14 Oct 2007, 3:38 AM
i see there is a proxy implementation, which one is better?

my idea is to read json in the last, mean, after the form generated, and click, read, show up.

the idea look like xml-form

Animal
14 Oct 2007, 3:43 AM
Just return the simple json representation as described in http://extjs.com/learn/Manual:Forms:Result_Format#Load_Action

It's deadly simple.