我已經轉換從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