用nodered提取json [英] extract json with nodered
问题描述
我想提取带有红色节点的消息中的 json 部分
我收到红色节点的消息,但我无法提取数据消息示例:
POST/HTTP/1.1主持人:xxx.xx.xxx.5:9000用户代理:libcurl-agent/1.0内容类型:应用程序/json接受:应用程序/json内容长度:526{时间戳":1571997083,数据": {温度":20.613545532227,湿度":61.3828125,电池":3.47},框架":814962xxxx16a1dc5","gatewayID": "AA555Axxxx0xx964","othersGW": [],"clientID": "xxxx","DevAddr": "011xxxxb","DevEUI": "8cf9xxx000000xxx","sensorInstallId": "8cf95xxx0000xxxx","loraPort": 8,fcnt":1607,rxpk":{tmst":2380181019,"时间": "2019-10-25T09:51:23.472998Z",陈":0,"rfch": 0,频率":867.1,统计":1,"modu": "LORA","datr": "SF7BW125","codr": "4/5","lsnr": 9,rssi":-72,大小":22,数据":xxxxxxxxxxxxxxxx/YxWg=="}}
所以我想要温度等数据...我不知道我必须使用的节点
非常感谢
从评论中更好地了解您要执行的操作.
使用 TCP-in
节点可能不是正确的方法.使用 HTTP-in
/HTTP-out
节点会做得更好,因为它们将处理所有 HTTP 标头并向客户端发送正确的响应,以便连接关闭.
HTTP-in
节点采用路径,例如/input
将附加到 Node-RED URL,给出类似于 http://localhost:1880/input
的内容.它还需要一个 HTTP 动词,在本例中为 POST
.您可以在 此处 的 Node-RED 说明书中找到更多详细信息和大量示例.>
您需要更新客户端以指向正确的路径和端口.
I want to extract json part in a message with node red
I receive the message in node red but I can't extract the data exemple of a message:
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=="
}
}
so I would like to have data of temperature etc... and I don't know the node I have to use
Thanks a lot
Having got a better view of what you are trying to do from the comments.
Using the TCP-in
node is probably not the right approach for this. You will do much better using the HTTP-in
/HTTP-out
nodes as these will handle dealing with all the HTTP-header and sending a proper response to the client so the connection gets closed.
The HTTP-in
node takes a path e.g. /input
which will be appended to the Node-RED URL giving something like http://localhost:1880/input
. It also takes a HTTP verb which in this case would be POST
. You can find more details and lots of examples in the Node-RED cookbook here.
You will need to update the client to point to the correct path and port.
这篇关于用nodered提取json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!