var jsonFormat = function (json) {
var format = function (json) {
var result = [];
if(typeIs(json, 'Object')) {
Object.keys(json).forEach(function (key) {
var value = json[key];
var item = {
key: key,
value: format(value)
}
result.push(item)
})
}else if(typeIs(json, 'Array') && typeIs(json[0], 'Object')) {
result = format(json[0]);
}else {
result = json;
}
return result;
}
return format(json);
}
网友评论