描述和目標: 本質數據每隔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