JSON 中的多词对象名称,node-red

Multiple word object name in JSON, node-red

我在解析来自 JSON 名称超过 1 个单词的对象的数据时遇到问题,我必须怎么做才能在另一个节点之前的函数节点中成功调用它。用什么代替星星来让它发挥作用?

感谢每个回答,谢谢

var array[];
for(var i = 0, i < msg.payload.*Time Series (Daily)*.length, i++){
array = msg.payload.*Time Series (Daily)*.*2020-12-10*.*2. high*
}
return array
{
    "Meta Data": {
        "1. Information": "Daily Time Series with Splits and Dividend Events",
        "2. Symbol": "AAPL",
        "3. Last Refreshed": "2020-12-10",
        "4. Output Size": "Compact",
        "5. Time Zone": "US/Eastern"
    },
    "Time Series (Daily)": {
        "2020-12-10": {
            "1. open": "120.5",
            "2. high": "123.87",
            "3. low": "120.15",
            "4. close": "123.24",
            "5. adjusted close": "123.24",
            "6. volume": "81312170",
            "7. dividend amount": "0.0000",
            "8. split coefficient": "1.0"
        }

您可以在方括号内使用字符串文字来访问带有空格、保留字等的属性。这也可用于赋值。

const myObject = {
  'a key with spaces': true,
  'return': 'this is a property whose key is the word "return"'
};

myObject['a new prop'] = 'Hello';

console.log(myObject['a key with spaces'], myObject['return']);

对于您的特定用例:

array = msg.payload['Time Series (Daily)']['2020-12-10']['2. high']