我收到了这条消息:
"data: "{"cmd":"gw","seqno":515816,"EUI":"000DB53113683569","ts":1510584501221,"fcnt":1,"port":2,"freq":868100000,"toa":1482,"dr":"SF12 BW125 4/5","ack":false,"gws":[{"rssi":-71,"snr":9.5,"ts":1510584501221,"time":"2017-11-13T14:48:21.218869Z","gweui":"B827EBFFFF6A14DD","lat":50.0751806,"lon":14.4022641}],"bat":255,"data":"0002560000000000000000"}""
我需要收集"数据:"并且最后"
如果我使用JSON节点,我只需要JSON消息它只是因为"数据而写了一个错误:"
答案 0 :(得分:0)
您可以使用功能节点来剪切字符串。像这样:
msg.payload = msg.payload.substring(7,msg.payload.length - 1);
return msg;
然后将其连接到JSON节点。
答案 1 :(得分:0)
作为替代方案,您可以添加缺少的{}
,然后添加JSON.parse。
var string = "{" + msg.payload +"}"
var dataObject = JSON.parse(string)
msg.payload = dataObject.data
return msg