NodeJS/Javascript select 以#开头的对象?
NodeJS/Javascript select a object starting with #?
这是我的回复:
{ artist:
{ '#text': 'Sam Smith',
mbid: '5a85c140-dcf9-4dd2-b2c8-aff0471549f3' },
song: 'Stay with Me',
from:
{ '#text': 'In the Lonely Hour',
mbid: 'f43d20c0-2fa5-4bc2-9c42-c677e346e768' } }
现在我想 select 艺术家姓名,( "#text" ) 但如何 select 以 # 开头的 属性?
你可以像这样使用bracket notation
console.log(data.artist['#text'])
这是我的回复:
{ artist:
{ '#text': 'Sam Smith',
mbid: '5a85c140-dcf9-4dd2-b2c8-aff0471549f3' },
song: 'Stay with Me',
from:
{ '#text': 'In the Lonely Hour',
mbid: 'f43d20c0-2fa5-4bc2-9c42-c677e346e768' } }
现在我想 select 艺术家姓名,( "#text" ) 但如何 select 以 # 开头的 属性?
你可以像这样使用bracket notation
console.log(data.artist['#text'])