'Advice on extracting data from JSON stream
I have a JSON data stream which contains a bunch of JSON objects prefixed with the 'Data: ' label. What is the simplest way to make this valid JSON so I can utilise the data stream in an application? The URL given is constantly updating so it has no end.
Short snippet of some of the streamed data:
data: {"value":12,"id":"window_doneTodayCount_1","updatedAt":1646316313574}
data: {"value":"4:30","id":"window_averageTime_1","updatedAt":1646316313596}
data: {"value":"Tue 11:05","id":"window_lastUpdatedTime","updatedAt":1646316313746}
I am looking to convert this dynamically to something like the below, which would be valid and I can use within an app:
[{
"value": 12,
"id": "window_doneTodayCount_1",
"updatedAt": 1646316313574
},
{
"value": "4:30",
"id": "window_averageTime_1",
"updatedAt": 1646316313596
}, {
"value": "Tue 11:05",
"id": "window_lastUpdatedTime",
"updatedAt": 1646316313746
}
]
Not even sure if this is possible as I have never seen a file like this.
Thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|