gpt4 book ai didi

javascript - 如何访问包含特殊字符的对象属性?

转载 作者:行者123 更新时间:2023-11-28 14:18:18 26 4
gpt4 key购买 nike

如何访问名称包含数字、点和空格的对象属性?

我的 REST API 响应是:

{
"Global Quote": {
"01. symbol": "WDI.FRK",
"02. open": "147.5000",
"03. high": "150.1000",
"04. low": "130.3000",
"05. price": "139.7500",
"06. volume": "79625",
"07. latest trading day": "2019-05-31",
"08. previous close": "154.0000",
"09. change": "-14.2500",
"10. change percent": "-9.2532%"
}
}

此表示法不起作用:

  var data                  = response;
var price= data.Global%x20Quote.05.%x20price;

最佳答案

这应该有效:const Price = data['Global Quote']['05.价格']

关于javascript - 如何访问包含特殊字符的对象属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56417088/

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