Javascript Sencha Touch-存储包含数组的JSON文件

Javascript Sencha Touch-存储包含数组的JSON文件,javascript,json,sencha-touch,extjs,sencha-touch-2,Javascript,Json,Sencha Touch,Extjs,Sencha Touch 2,可能重复: 我想将以下JSON文件解析到我的Sencha Touch应用程序中。我无法确定要使用哪种类型的“存储”(存储、JsonStore、ArrayStore等)以及“字段”设置是什么样的。数组中的每个“数据点”都应存储为xValue和yValue。我不明白没有单独的标签怎么能读这些点 [{"target": "stats.server1", "datapoints": [[22, 34], [99, 12], [13, 15], [56, 12], [34, 2], [13, 23],

可能重复:

我想将以下JSON文件解析到我的Sencha Touch应用程序中。我无法确定要使用哪种类型的“存储”(存储、JsonStore、ArrayStore等)以及“字段”设置是什么样的。数组中的每个“数据点”都应存储为xValue和yValue。我不明白没有单独的标签怎么能读这些点

[{"target": "stats.server1", "datapoints": [[22, 34], [99, 12], [13, 15], [56, 12], [34, 2], [13, 23], [23, 34], [55, 88]]},{"target": "stats.server2", "datapoints": [[22, 34], [99, 12], [13, 15], [56, 12], [34, 2], [13, 23], [23, 34], [55, 88]]}]

任何帮助都将不胜感激

以下代码是针对ExtJS4.1的,但据我所知,Touch2中的数据框架是相同的

// A reader defines how to process incoming data.
Ext.define('My.PointsReader', {
    extend: 'Ext.data.reader.Json',
    alias: 'reader.points',
    getData: function(data) {       // overriding
        data = this.callParent(arguments);
        var result = [];
        Ext.each(data, function(entry) {
            Ext.each(entry.datapoints || [], function(point) {
                result.push({
                    xValue: point[0], yValue: point[1],
                    target: entry.target
                });
            });
        });
        return result;
    }
});

// A store is always Ext.data.Store (or TreeStore, for trees).
// But its proxy, reader and writer can be customized.
var store = Ext.create('Ext.data.Store', {
        fields: ['xValue', 'yValue', 'target'],
        proxy: {
            type: 'ajax',
            url: 'test.json',
            reader: 'points'
        }
    });

store.load();

请避免问同样的问题,即使你仍然回答。非常感谢。如何将如上所示的“目标”集成到此解决方案中?假设每组数据点都有一个目标。“target”,意思是JSON中的“target”键file@user1467584但在您的示例中,对于所有
数据点
,您只有一个
目标。
。很抱歉……我已经更新了上面的示例,使其更加准确。@user1467584请参阅更新的答案。