Node-red split data

Hi,
I want to split the data in "field1" and "field2", but I not very sure how to do it. Someones help will be very much appreciated.

Thank you.

You say split the data. When I look at the debug message I see an array msg.payload.channel.feeds with historical data, and msg.payload.channel.field1 as well as msg.payload.channel.field2 which appear to be textual headers. What is the end result you're looking for? When you say split, do you want variables for field1 and field containing the list of values from the historical data in channel.feeds, or something else entirely?

A function node that parses msg.payload.channel might be an option, you could take a look at array.forEach() or array.map() to work through the feeds array.

1 Like

Thanks a lot for your reply.
Yes, by 'Split data", I mean to extract we values of "Field1" and "Field2" from the msg.payload String.
The methods that you had suggested didn't worked as the msg is a String and not an Array.

Thank you
Kind Regards

The payload seems to be a JSON. Feed it to json node and attach debug node to see what kind of data you will see from json node output.

1 Like

Thank you @hotNipi for your reply.

Now I'm getting the desired data, after adding the json.

Thank you

Kind Regards