小编Rau*_*hez的帖子

如何从 JSON 文件中提取数据

我有 bin 为我的问题搜索解决方案,但没有找到一个或更好的说法我没有得到我发现的东西。所以让我们谈谈我的问题是什么。我在 Raspberry Pi 上使用智能家居控制软件,本周末我发现使用 pilight-receive 可以从室外温度传感器获取数据。pilight-receive 的输出如下所示:

{
        "message": {
                "id": 4095,
                "temperature": 409.5
        },
        "origin": "receiver",
        "protocol": "alecto_wsd17",
        "uuid": "0000-b8-27-eb-0f3db7",
        "repeats": 3
}
{
        "message": {
                "id": 1490,
                "temperature": 25.1,
                "humidity": 40.0,
                "battery": 1
        },
        "origin": "receiver",
        "protocol": "alecto_ws1700",
        "uuid": "0000-b8-27-eb-0f3db7",
        "repeats": 3
}
{
        "message": {
                "id": 2039,
                "temperature": 409.5
        },
        "origin": "receiver",
        "protocol": "alecto_wsd17",
        "uuid": "0000-b8-27-eb-0f3db7",
        "repeats": 4
}
Run Code Online (Sandbox Code Playgroud)

现在我要问你:我怎么能从 id 为 1490 的地方提取温度和湿度。你会如何建议我经常检查这个?通过每 10 分钟运行一次的 cron 作业,创建 pilight-receive 的输出,提取输出的数据并将其推送到智能家居控制 Api。

有人有想法 - 非常感谢

text-processing json

18
推荐指数
1
解决办法
7万
查看次数

标签 统计

json ×1

text-processing ×1