Sencha Touch JSON Format

↘锁芯ラ 提交于 2020-01-11 13:29:09

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/11110380/sencha-touch-json-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!