描述和目标: 本质数据每隔2分钟到JSON数据被不断地生成。我需要做的是从提供的JSON数据中检索信息。数据将不断变化。信息解析后,需要将其捕获到可用于其他功能的变量中。循环解析JSON数据
我被困在试图找出如何创建一个函数有一个循环,重新分配所有的数据到可以稍后在函数中使用存储的变量是什么。
实施例的信息:
var json = {"data":
{"shop":[
{
"carID":"7",
"Garage":"7",
"Mechanic":"Michael Jamison",
"notificationsType":"repair",
"notificationsDesc":"Blown Head gasket and two rail mounts",
"notificationsDate":07/22/2011,
"notificationsTime":"00:02:18"
},
{
"CarID":"8",
"Garage":"7",
"Mechanic":"Tom Bennett",
"notificationsType":"event",
"notifications":"blown engine, 2 tires, and safety inspection",
"notificationsDate":"16 April 2008",
"notificationsTime":"08:26:24"
}
]
}};
function GetInformationToReassign(){
var i;
for(i=0; i<json.data.shop.length; i++)
{
//Then the data is looped, stored into multi-dimensional arrays that can be indexed.
}
}
所以结束结果必须是这样的:
shop[0]={7,7,"Michael Jamison",repair,"Blown Head gasket and two rail mounts", 07/22/2011,00:02:18 }
店[1] = {}
你应该看看很简单[JSON-语法](http://www.json.org/) – Saxoier