Query details in a JSON with URL commands -


i have json file, see below. url json file http://host/json. there way in url add options, displays value of switch, relay 2?

(this json file espeasy of esp8266's)

{"system":{ "build": 118, "unit": 2, "uptime": 68, "free ram": 28488 }, "sensors":[ { "taskname": "switch", "relay1": 0.00 }, { "taskname": "switch", "relay2": 0.00 }, { "taskname": "switch", "relay3": 0.00 }, { "taskname": "switch", "relay4": 0.00 }, { "taskname": "switch", "relay5": 0.00 }, { "taskname": "switch", "relay6": 0.00 }, { "taskname": "water", "countermunicipality": 0.00, "total": 0.00, "time": 0.00 }, { "taskname": "water", "counterborehole": 0.00, "total": 1.00, "time": 726077.00 }, { "taskname": "air", "temperature": nan, "humidity": nan }, { "taskname": "system", "uptime": 65.00 } ]} 

looking source code webserver.ino, should possible select task using tasknr argument see :

boolean handle_json() {     string tasknr = webserver.arg("tasknr"); ....     byte tasknr = tasknr.toint();     byte firsttaskindex = 0;     byte lasttaskindex = tasks_max - 1;     if (tasknr != 0 )     {         firsttaskindex = tasknr - 1;         lasttaskindex = tasknr - 1;     } ... } 

then should relay 2 using :

http://host/json?tasknr=2


Comments