PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, July 12, 2022

[FIXED] How can i seperate/split part of string messege in node red

 July 12, 2022     json, message, node-red, string     No comments   

Issue

I received this message:

 "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"}"" 

I need to put away the "data: " and on the end the "

I need just the JSON message if I use JSON node it just writes me an error because of the "data: "


Solution

You can use a function node to chop the string up. Something like this:

msg.payload = msg.payload.substring(7,msg.payload.length - 1);
return msg;

And then wire this to a JSON node.



Answered By - hardillb
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing