我有一个由php生成的数组:
(
[1] => Array
(
[url] => files/logo.png
[time] => 23 Mar 2016
[size] => 1.45KB
)
[2] => Array
(
[url] => files/print.png
[ftime] => 23 Mar 2016
[size] => 3.75B
)
[0] => Array
(
[url] => files/empty.jpg
[ftime] => 03 Apr 2015
[size] => 10.80KB
)
)
但是当我用json_encode运行它并通过ajax检索它时:
$.get(files.php", {
findFiles: "1",
}).done(function(json) {
var obj = $.parseJSON(json);
console.log(obj)
}, "json");
我最终得到了:
{
"files":[
{
"url":"files\/empty.jpg",
"ftime":"03 Apr 2015",
"size":"10.80KB",
},
{
"url":"files\/logo.png",
"ftime":"23 Mar 2016",
"size":"1.45KB",
},
{
"url":"files\/print.png",
"ftime":"23 Mar 2016",
"size":"3.75B",
}
]
}
它总是重置从0索引开始的数组。有没有办法阻止$ .parseJSON重置数组,并保持相同的顺序?