我有以下格式的以下Json数据......
var oData = [
{
"0":
{
"firstname": "aaa",
"lastname": "zzz",
"Email": "aaa@test.com"
},
"1":
{
"firstname": "bbb",
"lastname": "yyy",
"Email": "bbb@test.com"
},
"2":
{
"firstname": "ccc",
"lastname": "www",
"Email": "ccc@test.com"
}
}];
我们可以转换为以下格式吗?
var rData = [
{
"firstname": "aaa",
"lastname": "zzz",
"Email": "aaa@test.com"
},
{
"firstname": "bbb",
"lastname": "yyy",
"Email": "bbb@test.com"
},
{
"firstname": "ccc",
"lastname": "www",
"Email": "ccc@test.com"
}];
答案 0 :(得分:1)
var oData = [{
"0":
{
"firstname": "aaa",
"lastname": "zzz",
"Email": "aaa@test.com"
},
"1":
{
"firstname": "bbb",
"lastname": "yyy",
"Email": "bbb@test.com"
},
"2":
{
"firstname": "ccc",
"lastname": "www",
"Email": "ccc@test.com"
}
}],
data = oData[0],
rData = [];
JSON.stringify( data, function( key, value ) {
rData.push( value );
});
console.log( rData );