LogicMachine Forum
http request json (dxsEntries) Kostal - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: http request json (dxsEntries) Kostal (/showthread.php?tid=3374)



http request json (dxsEntries) Kostal - mlhxy - 17.05.2021

I need help. I don't know what I'm doing wrong to put the value in a group address.

Thanks for your help






Code:
require('json') http = require('socket.http') require('socket.url') url= 'http://192.168.2.11/api/dxs.json?dxsEntries=33556229' url = string.format(url)                                                                                   res = http.request(url) data = json.pdecode(res) if type(data) ~= 'table' then alert('failed to load data')   return end if data.error then   log('error', data.error)   return end dxsEntries = data.dxsEntries log(dxsEntries) grp.write('32/4/10', dxsEntries.value)                                                                                                       









RE: http request json (dxsEntries) Kostal - admin - 18.05.2021

Try this:
Code:
require('json') http = require('socket.http') url= 'http://192.168.2.11/api/dxs.json?dxsEntries=33556229' res = http.request(url) data = json.pdecode(res) if type(data) ~= 'table' then   alert('failed to load data')   return end if data.error then   log('error', data.error)   return end dxsEntries = data.dxsEntries[1] -- first array/table element log(dxsEntries) grp.checkwrite('32/4/10', dxsEntries.value)