json - 用nodered提取json
问题描述
我想在带有节点红色的消息中提取 json 部分
我收到红色节点的消息,但无法提取消息的数据示例:
POST / HTTP/1.1
Host: xxx.xx.xxx.5:9000
User-Agent: libcurl-agent/1.0
Content-type: application/json
Accept: application/json
Content-Length: 526
{
"timestamp": 1571997083,
"data": {
"temperature": 20.613545532227,
"humidity": 61.3828125,
"battery": 3.47
},
"frame": "814962xxxx16a1dc5",
"gatewayID": "AA555Axxxx0xx964",
"othersGW": [],
"clientID": "xxxx",
"DevAddr": "011xxxxb",
"DevEUI": "8cf9xxx000000xxx",
"sensorInstallId": "8cf95xxx0000xxxx",
"loraPort": 8,
"fcnt": 1607,
"rxpk": {
"tmst": 2380181019,
"time": "2019-10-25T09:51:23.472998Z",
"chan": 0,
"rfch": 0,
"freq": 867.1,
"stat": 1,
"modu": "LORA",
"datr": "SF7BW125",
"codr": "4/5",
"lsnr": 9,
"rssi": -72,
"size": 22,
"data": "xxxxxxxxxxxxxxxx/YxWg=="
}
}
所以我想要温度等数据......我不知道我必须使用的节点
非常感谢
解决方案
从评论中更好地了解您正在尝试做什么。
使用TCP-in
节点可能不是正确的方法。HTTP-in
使用/节点会做得更好,HTTP-out
因为它们将处理所有 HTTP 标头并向客户端发送正确的响应,以便关闭连接。
该HTTP-in
节点采用一个路径,例如,该路径/input
将附加到 Node-RED URL 中,给出类似http://localhost:1880/input
. 它还需要一个 HTTP 动词,在这种情况下是POST
. 您可以在此处的 Node-RED 食谱中找到更多详细信息和大量示例。
您需要更新客户端以指向正确的路径和端口。
推荐阅读
- python - pandas 将嵌套字典转换为 mutiIndex 行和列
- javascript - javascript如何在循环中并行使用异步等待
- javascript - 在js中逐行获取dom文本
- python - 不推荐使用调试参数。执行时 Python 记录库错误
- css - 为什么我的电话和传真 p 标签在苹果移动设备的页脚中出现错误?
- regex - 使用 sed 时缺少空格
- python - Pandas:df.query() 方法返回 0 个结果
- spring-boot - 使用 Spring Cloud Stream Kafka Binder 时无法设置 groupId 和 clientId
- nativescript - 底部导航程序化导航
- jquery - 日期时间选择器输入的 onchange