I am looking for help with the json api answer:
{ "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%" } }
I would like to pull the variable of "05. price".
when I do json.decode it tells me that this is table not string
when I do print(item["Global Quote"][5]) i got (a nil value)
when i do: for x,y in pairs(item) do print(y)
i got:
"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%"
Lua pull from json [Solved]
Moderator: leecollings
Re: Lua pull from json [Solved]
I managed to resolve my issue.
After i added:
local json = domoticz.utils.fromJSON(item.data)
I am able to index through the table. (json["Global Quote"]["05. price"])
After i added:
local json = domoticz.utils.fromJSON(item.data)
I am able to index through the table. (json["Global Quote"]["05. price"])
Who is online
Users browsing this forum: No registered users and 1 guest