Lua pull from json
Posted: Wednesday 23 October 2019 18:26
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%"
{ "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%"