我怎样才能从以下类型的json中读取颜色?

时间:2012-05-04 12:44:22

标签: javascript json

{
  "events": [
    [
      1,
      "arun Thakur",
      "04/30/2012 00:00",
      "04/30/2012 00:00",
      1,
      0,
      0,
      "11",
      1,
      "New Delhi",
      ""
    ],
    [
      3,
      "ryurts",
      "05/02/2012 01:30",
      "05/02/2012 04:30",
      0,
      0,
      0,
      "blue",
      1,
      "",
      ""
    ],
    [
      7,
      "Sandeep Singh",
      "05/01/2012 00:00",
      "05/01/2012 01:30",
      0,
      0,
      0,
      "blue",
      1,
      "sadasdasfdg",
      ""
    ],
    [
      9,
      "sadasdsdsa",
      "05/02/2012 00:00",
      "05/02/2012 00:00",
      1,
      0,
      0,
      "yellow",
      1,
      "",
      ""
    ],
    [
      11,
      "Hello World",
      "04/30/2012 00:00",
      "04/30/2012 00:00",
      1,
      0,
      0,
      "",
      1,
      "",
      ""
    ]
  ],
  "issort": true,
  "start": "04/30/2012 00:00",
  "end": "05/06/2012 23:59",
  "error": null
}

1 个答案:

答案 0 :(得分:2)

其中一些项目没有颜色,数据结构不合理,但这似乎是您想要的:

var json = <your data here>;

for(var i = 0; i < json.events.length; i++) {
    var item = json.events[i];
    console.log(item[7]);
}

我只是将颜色打印到控制台。大概你会在那里放一些更有用的代码。