# Node-red split data

**URL:** <https://discourse.nodered.org/t/node-red-split-data/12619>\
**Category:** General\
**Created:** [26 June 2019 14:39 UTC](https://discourse.nodered.org/t/node-red-split-data/12619 "2019-06-26T14:39:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjbhuyan](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@mjbhuyan](https://discourse.nodered.org/u/mjbhuyan)\
**Post date:** [26 June 2019 14:39 UTC](https://discourse.nodered.org/t/node-red-split-data/12619/1 "2019-06-26T14:39:33Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d06ce1c344c6101ce0dcd5329af7ae15195b7d4d.png)

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [26 June 2019 15:35 UTC](https://discourse.nodered.org/t/node-red-split-data/12619/2 "2019-06-26T15:35:29Z")

</div>

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()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) or [`array.map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) to work through the `feeds` array.

---

<div class="post-metadata">

**Author:** ![mjbhuyan](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@mjbhuyan](https://discourse.nodered.org/u/mjbhuyan)\
**Post date:** [26 June 2019 16:00 UTC](https://discourse.nodered.org/t/node-red-split-data/12619/3 "2019-06-26T16:00:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [26 June 2019 16:11 UTC](https://discourse.nodered.org/t/node-red-split-data/12619/4 "2019-06-26T16:11:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mjbhuyan](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@mjbhuyan](https://discourse.nodered.org/u/mjbhuyan)\
**Post date:** [26 June 2019 17:33 UTC](https://discourse.nodered.org/t/node-red-split-data/12619/5 "2019-06-26T17:33:40Z")

</div>

Thank you @hotNipi for your reply.

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

Thank you

Kind Regards
