Sencha Touch JSON格式 [英] Sencha Touch JSON Format

查看:132
本文介绍了Sencha Touch JSON格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


[{target:stats.server14 ,datapoints:[[0.0,1340034660],
[0.016666666666666666,1340034720],[0.11666666666666667,1340034780],
[0.18333333333333332,1340034840],[0.05,1340034900],[0.0,
1340034960],[0.05,1340035020],[null,1340121000]]}]


我不知道如何解析这个,因为它包括元标签和嵌套数据点。



这是我迄今为止所做的:

  Ext.regModel('DataModel',{
fields:[
{name:'target',type:'string'},
{name:'datapoints' ,键入:'string'}
]

它只返回一个大的数据点字符串,我想把它们分成xValue,yValue的。



任何帮助将不胜感激!

解决案

不管你值传递到数据点字段被自动转换为字符串,因为你给它输入串。删除此部分(即将整个类型:string从数据点列出)。



给你更接近你想要的数据点。如果不完全是你想要的,你可以使用 convert 函数调整数据点,参见 Ext.data.Field


I'm trying to input a JSON file with the following format:

[{"target": "stats.server14", "datapoints": [[0.0, 1340034660], [0.016666666666666666, 1340034720], [0.11666666666666667, 1340034780], [0.18333333333333332, 1340034840], [0.05, 1340034900], [0.0, 1340034960], [0.05, 1340035020],[null, 1340121000]]}]

I cannot figure out how to parse this, as it includes metatags and nested data points.

Here is what I have so far:

    Ext.regModel('DataModel', {
        fields: [
            {name: 'target', type: 'string'},
            {name: 'datapoints', type: 'string'}
        ]

It just returns the data points in one big string. I'd like to have them broken into xValue, yValue's.

Any help would be greatly appreciated!

解决方案

Whatever value you pass into the datapoints field automatically gets converted to a string, because you gave it type "string". Remove this part (i.e. leave the whole type: "string" out of the datapoints line).

This should give you datapoints that are closer to what you want. If it's not entirely what you want, you can tweak the datapoints by using the convert function, see Ext.data.Field.

这篇关于Sencha Touch JSON格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆