Json table in in lua

问题描述 投票:0回答:1

我正在寻求有关json api答案的帮助:

{
    "Global Quote": {
        "01. symbol": "GLG",
        "02. open": "0.4780",
        "03. high": "0.4800",
        "04. low": "0.4650",
        "05. price": "0.4760",
        "06. volume": "14183",
        "07. latest trading day": "2019-10-23",
        "08. previous close": "0.4754",
        "09. change": "0.0006",
        "10. change percent": "0.1262%"
    }
}

我想提取05. price的变量。]​​>

这是我的脚本:

return {
    on = {
        timer = {'every 10 minutes'},
        httpResponses = {'MSI'}

    },
    logging = {
        level = domoticz.LOG_DEBUG,
        marker = "msi"
    },
    execute = function(domoticz, item)
        if (item.isTimer) then
            domoticz.openURL({
                url = 'https://www.alphavantage.co/query? 
                function=GLOBAL_QUOTE&symbol=MSI&apikey=................',
                method = 'GET',
                callback = 'MSI'
            })
        end
        if (item.isHTTPResponse and item.statusCode == 200) then
            domoticz.devices('MSI').updateCustomSensor(item.json["Global Quote"] 
            ["05. price"])
        ))     
    end 
end
}

我正在寻求有关json api的帮助:{“ Global Quote”:{“ 01. symbol”:“ GLG”,“ 02. open”:“ 0.4780”,“ 03. high”:“ 0.4800”, “ 04.低”:“ 0.4650”,“ ...

json lua
1个回答
0
投票

本地json = domoticz.utils.fromJSON(item.data)帮助

© www.soinside.com 2019 - 2024. All rights reserved.