gpt4 book ai didi

javascript - NodeJS/Javascript 选择一个以 # 开头的对象?

转载 作者:行者123 更新时间:2023-12-02 16:36:47 25 4
gpt4 key购买 nike

这是我的回复:

{ 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' } }

现在我想选择艺术家姓名(“#text”),但如何选择以#开头的属性?

最佳答案

您可以使用bracket notation ,像这样

console.log(data.artist['#text'])

关于javascript - NodeJS/Javascript 选择一个以 # 开头的对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27865067/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com