json with dash '-' in object name

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
hestia
Posts: 361
Joined: Monday 25 December 2017 23:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Paris
Contact:

json with dash '-' in object name

Post by hestia »

how to use a object from a json when the name of this object contains a dash '-'
example:
triggerObject.json.currently.time) => OK
triggerObject.json.flags.nearest-station) => KO :-(

to use https://darksky.net/dev/docs#overview
gerardvs
Posts: 81
Joined: Sunday 04 January 2015 0:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest-1
Location: /dev/null
Contact:

Re: json with dash '-' in object name

Post by gerardvs »

Try ["nearest-station"]
hestia
Posts: 361
Joined: Monday 25 December 2017 23:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Paris
Contact:

Re: json with dash '-' in object name

Post by hestia »

Thanks gerardvs
but it doesn't work :-(
=> lua:171: <name> expected near '['
elmortero
Posts: 247
Joined: Sunday 29 November 2015 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9639
Location: Spain
Contact:

Re: json with dash '-' in object name

Post by elmortero »

triggerObject.json.flags["nearest-station"] (no . before [ )
hestia
Posts: 361
Joined: Monday 25 December 2017 23:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Paris
Contact:

Re: json with dash '-' in object name

Post by hestia »

Thanks elmortero

print('nearest-station: '.. triggerObject.json.flags["nearest-station"]) => OK

bravo!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest