问题
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