json 含多层子属性

1,


a:
b: { ba:  bb: }

//1to1

var data = {
	totalProperty:1,
	root:[{ 'a': '1','b':{'ba': '21','bb':'22'}}]
};



var reader = new Ext.data.JsonReader({
   totalProperty: 'totalProperty',
   root:'root'	
},[
   {name:'a'},
   {name:'b_ba',mapping:'b.ba'},
   {name:'b.bb',mapping:'b.bb'}
])

ColumnModel:
   {header:'A',dataIndex:'a'},
   {header:'B.BA',dataIndex:'b_ba'},
   {header:'B.BB',dataIndex:'b.bb'},



2,



a:
b: [{ ba: },{ bb: }]


//b:list
var data = {
	totalProperty:1,
	root:[{ 'a': '1','b':{'ba': '21','bb':'22'}}]
};



var reader = new Ext.data.JsonReader({
   totalProperty: 'totalProperty',
   root:'root'	
},[
   {name:'a'},
   {name:'b_ba',mapping:'[color=green]b[0][/color].ba'},
   {name:'b.bb',mapping:'[color=green]b[1][/color].bb'}
])

ColumnModel:
   {header:'A',dataIndex:'a'},
   {header:'B.BA',dataIndex:'b_ba'},
   {header:'B.BB',dataIndex:'b.bb'},



你可能感兴趣的:(java,json,ext)