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

问题描述

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



这是我迄今为止所做的:

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

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



任何帮助将不胜感激!

解决案

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



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


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

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格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 04:57