dzVents OpenURL - Error parsing json to LUA table: (invalid json string)
Posted: Wednesday 13 July 2022 18:48
Hi,
I am trying to get the weather details from this link
The result from the openurl is in the following format:
[{"SDATA":"2022-07-12 18:00","TZ":5.9,"TP":8.2},{"SDATA":"2022-07-12 19:00","TZ":5.9,"TP":7.7},{"SDATA":"2022-07-12 20:00","TZ":5.9,"TP":7.5},{"SDATA":"2022-07-12 21:00","TZ":"NaN","TP":7.7},{"SDATA":"2022-07-12 22:00","TZ":6.3,"TP":7.7},{"SDATA":"2022-07-12 23:00","TZ":6.1,"TP":8},{"SDATA":"2022-07-13 00:00","TZ":6.1,"TP":8.2},{"SDATA":"2022-07-13 01:00","TZ":6.1,"TP":7.7},{"SDATA":"2022-07-13 02:00","TZ":5.9,"TP":8},{"SDATA":"2022-07-13 03:00","TZ":5.9,"TP":8.4},{"SDATA":"2022-07-13 04:00","TZ":5.6,"TP":8.2},{"SDATA":"2022-07-13 05:00","TZ":5.6,"TP":8},{"SDATA":"2022-07-13 06:00","TZ":5.6,"TP":8},{"SDATA":"2022-07-13 07:00","TZ":5.4,"TP":7.3},{"SDATA":"2022-07-13 08:00","TZ":5.6,"TP":7.3},{"SDATA":"2022-07-13 09:00","TZ":5.4,"TP":7.7},{"SDATA":"2022-07-13 10:00","TZ":5.6,"TP":7.7},{"SDATA":"2022-07-13 11:00","TZ":5.4,"TP":7.3},{"SDATA":"2022-07-13 12:00","TZ":5.4,"TP":8.2},{"SDATA":"2022-07-13 13:00","TZ":5.6,"TP":8.4},{"SDATA":"2022-07-13 14:00","TZ":5.9,"TP":8.4},{"SDATA":"2022-07-13 15:00","TZ":5.6,"TP":8},{"SDATA":"2022-07-13 16:00","TZ":5.9,"TP":8},{"SDATA":"2022-07-13 17:00","TZ":"NaN","TP":"NaN"},{"SDATA":"2022-07-13 18:00","TZ":"NaN","TP":"NaN"}]
Now I am trying to retrieve the specific values from the output, converting the JSON to a LUA table but I think JSON format is not valid, so a get this error:
Looking in the forum, internet and the dzVents wiki but not getting any value out of it. Just working rawData doing something like this and something like
Any ideas? Appreciate your suggestions or hints in the right direction
I am trying to get the weather details from this link
The result from the openurl is in the following format:
[{"SDATA":"2022-07-12 18:00","TZ":5.9,"TP":8.2},{"SDATA":"2022-07-12 19:00","TZ":5.9,"TP":7.7},{"SDATA":"2022-07-12 20:00","TZ":5.9,"TP":7.5},{"SDATA":"2022-07-12 21:00","TZ":"NaN","TP":7.7},{"SDATA":"2022-07-12 22:00","TZ":6.3,"TP":7.7},{"SDATA":"2022-07-12 23:00","TZ":6.1,"TP":8},{"SDATA":"2022-07-13 00:00","TZ":6.1,"TP":8.2},{"SDATA":"2022-07-13 01:00","TZ":6.1,"TP":7.7},{"SDATA":"2022-07-13 02:00","TZ":5.9,"TP":8},{"SDATA":"2022-07-13 03:00","TZ":5.9,"TP":8.4},{"SDATA":"2022-07-13 04:00","TZ":5.6,"TP":8.2},{"SDATA":"2022-07-13 05:00","TZ":5.6,"TP":8},{"SDATA":"2022-07-13 06:00","TZ":5.6,"TP":8},{"SDATA":"2022-07-13 07:00","TZ":5.4,"TP":7.3},{"SDATA":"2022-07-13 08:00","TZ":5.6,"TP":7.3},{"SDATA":"2022-07-13 09:00","TZ":5.4,"TP":7.7},{"SDATA":"2022-07-13 10:00","TZ":5.6,"TP":7.7},{"SDATA":"2022-07-13 11:00","TZ":5.4,"TP":7.3},{"SDATA":"2022-07-13 12:00","TZ":5.4,"TP":8.2},{"SDATA":"2022-07-13 13:00","TZ":5.6,"TP":8.4},{"SDATA":"2022-07-13 14:00","TZ":5.9,"TP":8.4},{"SDATA":"2022-07-13 15:00","TZ":5.6,"TP":8},{"SDATA":"2022-07-13 16:00","TZ":5.9,"TP":8},{"SDATA":"2022-07-13 17:00","TZ":"NaN","TP":"NaN"},{"SDATA":"2022-07-13 18:00","TZ":"NaN","TP":"NaN"}]
Now I am trying to retrieve the specific values from the output, converting the JSON to a LUA table but I think JSON format is not valid, so a get this error:
Code: Select all
Error parsing json to LUA table: (invalid json string)
Code: Select all
local json = item.data:gsub("%[",""):gsub("%]","")
Code: Select all
dz.utils.stringSplit(json,',')