Split and Split Again

I am new to Node-Red so I hope that I can explain this in a way that makes sense. I am getting data from a program called Pira CZ that triggers when silence is on our station. It uses HTTP Get to input into Node Red and this is what it picks up.


I can change the format if it makes sense. I then need to run it through a function node so that I can split it.


I then split it at the commas to give me four separate values:


Now, I want to Split these so that the left is the key and the right is the value. I feel like this could be all done in the function node but I lack that level of programming. I am still learning and no better way then to figure out what hasn't worked but I am stumped at this point. I want to be able to log this information as well as send to the UI. There is also a message that will tell us when the station is back to normal as well.

If you select return a json object in the http request, you will get key value pairs in a javasript object. no need for all the spliting

Change your return to


If you can change the format, why don't you put each value in their own property?

I meant that I can send a single line formatted in different ways. I guess what I said is misleading or I am missing the approach you are suggesting?

JSON is a string. format the data as JSON then its a simple case of turning it into a JS object & accessing values like...


Question - do you generate this {"0":"STATION:KXKX,STATUS:SILENT,DATE:2020-10-13,TIME:17-58-08"} or do you only generate STATION:KXKX,STATUS:SILENT,DATE:2020-10-13,TIME:17-58-08 ?

I am producing the first one. I get what you are saying and apologize for my lack of knowledge on JSON. Still learning all this. Appreciate the patience.

Can you format it like this then?

I sure can. I was about to reply to your earlier message. I am doing it know. I take it at that point I insert into the JSON node and convert?

if you want to or you can set the http request to return a json object, it will then decode your json string into a javascript object.

I have and this is what I see on the other side of the HTTP GET Node in the DEBUG.


you need to remove the {" from beginning and ":""} from end.

Or if not possible

Or show us a screeshot of how you are editing this string.

OK. I have learned a little more on how this program is adding the {" and the ":""}. It seems I can stop this by adding this in front 0= So the line looks like this in the program at this point:

This is the output now in the debug window:

I feel like I am getting a little closer.

OK that looks correct, now in the http request node change return a UTF-8 string to parse json object.

Also a screen shot of the debug msg expanded.

Thanks. I had to step away for some other work.

Here is the screenshot:
Screen Shot 2020-10-17 at 12.21.18 PM

I am actually using the HTTP IN node since the program sends an HTTP Get. I know that if I use the JSON expression it allows me to parse the data. I think I have just run into a limitation on what the software can send in the GET request.

Ok we can work with it that way
Try this to convert to object and remove the object [0]


I was thinking what happens if you structure your Pira CZ call like this


So Simple and so right. This did the trick. It formatted perfectly.

Yeah should have spotted it earlier. It was when you said that the software was making a get request, a idea popped in to my head.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.