煎茶触摸JSON格式 [英] Sencha Touch JSON Format

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

问题描述

我正在尝试输入以下格式的 JSON 文件:

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]]}]

[{"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.

这是我目前所拥有的:

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

它只返回一个大字符串中的数据点.我想让它们分解成 xValue 和 yValue.

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

任何帮助将不胜感激!

推荐答案

无论您传递到数据点字段中的任何值都会自动转换为字符串,因为您为其指定了类型字符串".删除这部分(即从数据点行中删除整个 type: "string").

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).

这应该会为您提供更接近您想要的数据点.如果这不完全是您想要的,您可以使用 convert 功能调整数据点,请参阅 Ext.data.Field.

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.

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

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