data =
{"user" : [
{
"id" : 1,
"name" : "jeboo",
"level": 1
},
{
"id" : 2,
"name" : "yoyo",
"level": 1
},
{
"id" : 3,
"name" : "yaya",
"level": 2
},
{
"id" : 4,
"name" : "yeye",
"level": 2
},
{
"id" : 5,
"name" : "yiyi",
"level": 3
},
{
"id" : 6,
"name" : "jebee",
"level": 3
}
]}
這是我如何得到JSON對象的我怎樣才能對JSON對象以JavaScript
var obj = JSON.stringify(data);
var parse = JSON.parse(obj);
$.each(parse, function(key, object) {
$.each(object, function(index, val) {
console.log(index, val);
});
});
我的目的是要產生下面
對象陣列0 +對象1 =第一對
對象2 +物體3 =第二對
對象4 +對象5 =第三對
你想要這些對在數組中嗎? –
for(var i = 0; i
[沒有這樣的東西作爲「JSON對象」](http://benalman.com/news/2010/03/theres -no-such-thing-as-a-json /) – str