我是hightcharts的新手,我在Chrome控制台上发现了一个错误。错误是"未捕获TypeError:无法读取属性' timestamp'未定义"。以下是我的代码:
Javascript.JS:
if(selVal==str2[j]) {
console.log("FOLDERNAME"+selVal);
str3.push(str2[j+1]);
}
var json = str3[0];
**//This is for highcharts where I am trying to load myjson that is present in "var json"**
for (var k = 0; k < json.length; k++) {
jsonArray.push({
name: json[k].map.timestamp,**//Getting error over here**
y:json[k].map.count
});
JSON格式:
[{"map":{"timestamp":"2016-01-09 05:55:42.0","count":367}}]
有人请帮我解决这个问题。我几乎尝试了一切。
答案 0 :(得分:1)
试试这个
var json=[{"map":{"timestamp":"2016-01-09 05:55:42.0","count":367}}];
/***This is for highcharts where I am trying to load myjson that is present in "var json"**/
var jsonArray=[];
for (var k = 0; k < json.length; k++) {
jsonArray.push({
name: json[k]["map"].timestamp,
y:json[k]["map"].count
});
}
console.log(jsonArray)