1、通过for-in获取
var json = {"name" : "Tom", "age" : 18};
var keyarr = [];
var valarr = [];
for(var key in json){
keyarr.push(key);
valarr.push(json[key]);
}
console.log(keyarr,valarr)
2、通过jquery的$.each获取
var json = {"name" : "Tom", "age" : 18};
var keyarr = [];
var valarr = [];
$.each(json, function(i) {
keyarr.push([i]);
valarr.push(json[i]);
});
console.log(keyarr,valarr)