我已经转换从XML JavaScript对象,此为示范对象:转换对象
{
name: 'current name',
attr1: 'attribute1',
attr2: 'attribute2',
address: {
name: 'name1',
value: {
value: '12'
},
attr3: {
name: 'no name',
attr4: {
attr4: 'attribute4'
}
}
},
price: {
price: '500'
},
in_house: {
in_house: '2'
}
}
我怎么能转换成这样:
{
name: 'current name',
attr1: 'attr1',
address:{
name: 'name1',
value: '12',
attr3: {
name: 'no name',
attr4: 'attribute3'
}
}
attr2: 'attr2',
price: 500,
in_house: 2
}
需要转换所有unusefull对象转换属性,例如 { 价: 价: '500' } 成 {价格: '500'}
如果CONSOLE.LOG你的对象,你会看到你的对象是无效的。我建议你在'价格'之前加'',''' –
谢谢@kevinternet – memoris