problem for reading json with lua

Moderator: leecollings

Post Reply
david31
Posts: 11
Joined: Thursday 07 January 2016 11:32
Target OS: Linux
Domoticz version: 3.8153
Contact:

problem for reading json with lua

Post by david31 »

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

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)
    
for extract data

Code: Select all

jsondevices.request_state
is ok
but for extract

Code: Select all

jsondevices.2018-03-14 04:00:00.pluie
domoticz return error on name 2018

the problem is the format of this label

Code: Select all

2018-03-14 04:00:00
Could you help me?

Sorry for my bad english
david31
Posts: 11
Joined: Thursday 07 January 2016 11:32
Target OS: Linux
Domoticz version: 3.8153
Contact:

Re: problem for reading json with lua

Post by david31 »

Thanks for your reponse

it's works fine !
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest