03.02.2022, 14:58
parsing the output is another thing:
line output: data: [{"creationtime":"2022-02-03T13:35:32Z","data":[{"id":"f2ef58b3-818e-45ea-a291-325e8eeb97bc","id_v1":"/lights/10","on":{"on":false},"owner":{"rid":"0120cec8-b58e-4206-a409-2bd99055af55","rtype":"device"},"type":"light"}],"id":"49142b93-3da7-49dc-9ad6-10809df8fe9d","type":"update"}]
This works
But the second output combines more lines, how to decode this line?
line output:
data: [{"creationtime":"2022-02-03T13:35:32Z","data":[{"id":"728be63c-dc61-42b1-9a84-54daeff76046","id_v1":"/groups/0","on":{"on":false},"type":"grouped_light"}],"id":"b201d09a-0ab2-4a60-b72f-3a099841ebbc","type":"update"},{"creationtime":"2022-02-03T13:35:32Z","data":[{"id":"33b4f136-c59e-4270-83af-814c4f5ba856","id_v1":"/groups/18","on":{"on":false},"type":"grouped_light"}],"id":"e2860e1b-ebd0-40b0-81ed-f1c0b27163a3","type":"update"},{"creationtime":"2022-02-03T13:35:32Z","data":[{"id":"7a8f900c-c312-403a-bf73-9d2fcb005489","id_v1":"/groups/19","on":{"on":false},"type":"grouped_light"}],"id":"1cc814e9-9210-4e75-92c0-29a543c32dcb","type":"update"}]
line output: data: [{"creationtime":"2022-02-03T13:35:32Z","data":[{"id":"f2ef58b3-818e-45ea-a291-325e8eeb97bc","id_v1":"/lights/10","on":{"on":false},"owner":{"rid":"0120cec8-b58e-4206-a409-2bd99055af55","rtype":"device"},"type":"light"}],"id":"49142b93-3da7-49dc-9ad6-10809df8fe9d","type":"update"}]
Code:
line = string.sub(line,8,-2) -- remove "data: [" and the last ] character
line = json.pdecode(line)
But the second output combines more lines, how to decode this line?
line output:
data: [{"creationtime":"2022-02-03T13:35:32Z","data":[{"id":"728be63c-dc61-42b1-9a84-54daeff76046","id_v1":"/groups/0","on":{"on":false},"type":"grouped_light"}],"id":"b201d09a-0ab2-4a60-b72f-3a099841ebbc","type":"update"},{"creationtime":"2022-02-03T13:35:32Z","data":[{"id":"33b4f136-c59e-4270-83af-814c4f5ba856","id_v1":"/groups/18","on":{"on":false},"type":"grouped_light"}],"id":"e2860e1b-ebd0-40b0-81ed-f1c0b27163a3","type":"update"},{"creationtime":"2022-02-03T13:35:32Z","data":[{"id":"7a8f900c-c312-403a-bf73-9d2fcb005489","id_v1":"/groups/19","on":{"on":false},"type":"grouped_light"}],"id":"1cc814e9-9210-4e75-92c0-29a543c32dcb","type":"update"}]