problem for reading json with lua
Posted: Wednesday 14 March 2018 15:11
Hello
I use many json data for extract data.
But with this file, i can't extract specific data
i read all the table only
the file
{
• request_state: 200,
• request_key: "fd543c77e33d6c8a5e218e948a19e487",
• message: "OK",
• model_run: "01",
• source: "internal:GFS:1",
• 2018-03-14 04:00:00:
{
o temperature:
{
2m: 279.6,
sol: 281,
500hPa: -0.1,
850hPa: -0.1
},
o pression:
{
niveau_de_la_mer: 101410
},
o pluie: 0,
o pluie_convective: 0,
o humidite:
{
2m: 76.4
}
I use this code for test
for extract data is ok
but for extract domoticz return error on name 2018
the problem is the format of this label
Could you help me?
Sorry for my bad english
I use many json data for extract data.
But with this file, i can't extract specific data
i read all the table only
the file
{
• request_state: 200,
• request_key: "fd543c77e33d6c8a5e218e948a19e487",
• message: "OK",
• model_run: "01",
• source: "internal:GFS:1",
• 2018-03-14 04:00:00:
{
o temperature:
{
2m: 279.6,
sol: 281,
500hPa: -0.1,
850hPa: -0.1
},
o pression:
{
niveau_de_la_mer: 101410
},
o pluie: 0,
o pluie_convective: 0,
o humidite:
{
2m: 76.4
}
I use this code for test
Code: Select all
JSON = (loadfile "/domoticz/scripts/lua/JSON.lua")()
local jsondata=assert(io.popen('curl "http://www.infoclimat.fr/public-api/gfs/json?_ll=43.48935,1.56807
local jsondevices = jsondata:read('*all')
jsondata:close()
local jsonLocation = JSON:decode(jsondevices)
Code: Select all
jsondevices.request_state
but for extract
Code: Select all
jsondevices.2018-03-14 04:00:00.pluie
the problem is the format of this label
Code: Select all
2018-03-14 04:00:00
Sorry for my bad english