curl (bash) and JSON
Posted: Tuesday 05 May 2020 15:54
Hello,
i'm trying to use curl on bash, as a mean to send to Domoticz via customerevents a JSON data string. I having problems with [] in bash.
The following code is sent to Domoticz, fires up the related custom event and is recognized as a valid JSON data structure
With data variable including a table in the JSON string, it does not even fireup custom event
I guess it is a matter of escaping [], I searched a lot with no success so far
dzvents 3.04
i'm trying to use curl on bash, as a mean to send to Domoticz via customerevents a JSON data string. I having problems with [] in bash.
The following code is sent to Domoticz, fires up the related custom event and is recognized as a valid JSON data structure
Code: Select all
data='\{"sensor":\{"port":2,"output":1,"power":1.13619548\},"status":"success"\}'
url=$DOMOTICZSERVER:$DOMOTICZPORT'/json.htm?type=command¶m=customevent&event=mFI&data='$data
curl --silent $url > /dev/null
Code: Select all
data='\{"sensors":[\{"port":2,"output":1,"power":1.13619548\}],"status":"success"\}'dzvents 3.04