关于从 JSON 流中提取数据的建议
我有一个 JSON 数据流,其中包含一堆以“Data:”标签为前缀的 JSON 对象。制作此有效 JSON 以便我可以在应用程序中利用数据流的最简单方法是什么?给出的 URL 会不断更新,因此没有尽头。
一些流数据的简短片段:
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}
我希望将其动态转换为如下所示的内容,这将是有效的,我可以在应用程序中使用:
[{
"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
}
]
甚至不确定这是否可能,因为我从未见过这样的文件。
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论