求大神帮忙!
{"IsSuccess":true,
"Data":{"Index":1,"Size":10,"RowCount":3,"PageCount":1,
"PageData":[{"Id":3,"GUID":"beca097f-acd8-4f28-8f32-3e1517aa568b","UserID":3,"UserGUID":"571f005f-4422-449c-8274-4da6f7aabf97","UserName":"王五","UserLoginName":"王五","UserLoginPassword":"4321","UserPhone":"654321","UserEmail":"[email protected]"},
{"Id":2,"GUID":"26ae1659-8e1d-424e-b7d4-77bb3af8e55d","UserID":2,"UserGUID":"15bdf47e-5a73-4944-ac56-e5eeca98a8d9","UserName":"李四","UserLoginName":"lisi","UserLoginPassword":"1234","UserPhone":"123456","UserEmail":"[email protected]"},
{"Id":1,"GUID":"7872a950-1773-4cef-819f-2dfd410a18f5","UserID":1,"UserGUID":"d868ee95-27f4-4841-be93-fdd04520d4b3","UserName":"张三","UserLoginName":"zhangsan","UserLoginPassword":"1111","UserPhone":"111111","UserEmail":"[email protected]"}]}}这种格式的json数据怎么解析,如何用一个数据模型接受,并且显示在grid里面

解决方案 »

  1.   

        Ext.onReady(function () {
            var store = Ext.create('Ext.data.Store', {
                fields: ["Id", "GUID", "UserID", "UserGUID", "UserName", "UserLoginName", "UserLoginPassword", "UserPhone", "UserEmail"],
                proxy: {
                    type: 'ajax',
                    url: 'data.txt',
                    reader: {
                        type: 'json',
                        root: 'Data.PageData'///ext可以直接配置root
                    }
                }, autoLoad: true
            });
            Ext.create('Ext.grid.Panel', {
                store: store,
                columns: [
            { text: 'Id', dataIndex: 'Id' },
            { text: 'GUID', dataIndex: 'GUID' },
            { text: 'GUID', dataIndex: 'GUID' },
            { text: 'UserName', dataIndex: 'UserName' }
        ],
                height: 200,
                width: 400,
                renderTo: Ext.getBody()
            });
        });
      

  2.   

    1楼的代码中的reader配置再加一行:successProperty:'IsSuccess'//(因为标示默认是“success”)
    即:Ext.onReady(function () {
            var store = Ext.create('Ext.data.Store', {
                fields: ["Id", "GUID", "UserID", "UserGUID", "UserName", "UserLoginName", "UserLoginPassword", "UserPhone", "UserEmail"],
                proxy: {
                    type: 'ajax',
                    url: 'data.txt',
                    reader: {
                        type: 'json',
                        successProperty:'IsSuccess',
                        root: 'Data.PageData'///ext可以直接配置root
                    }
                }, autoLoad: true
            });
         
         . . .  
            . . .(省略)
    是Extjs中的store获取数据的一种格式
      

  3.   

    Ext.decode()不就可以装换成对象