# I'm trying to use split to separate the content, but it doesn't meet my needs

**URL:** <https://discourse.nodered.org/t/im-trying-to-use-split-to-separate-the-content-but-it-doesnt-meet-my-needs/54264>\
**Category:** General\
**Created:** [25 November 2021 11:13 UTC](https://discourse.nodered.org/t/im-trying-to-use-split-to-separate-the-content-but-it-doesnt-meet-my-needs/54264 "2021-11-25T11:13:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cybertron](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cybertron/32/14683_2.png) [@Cybertron](https://discourse.nodered.org/u/Cybertron)\
**Post date:** [25 November 2021 11:13 UTC](https://discourse.nodered.org/t/im-trying-to-use-split-to-separate-the-content-but-it-doesnt-meet-my-needs/54264/1 "2021-11-25T11:13:31Z")

</div>

hello  
I'm browsing the course  
[https://nodered.org/docs/user-guide/messages#understanding-the-structure-of-a-message](https://nodered.org/docs/user-guide/messages#understanding-the-structure-of-a-message)  
I have a TCP connection originating content that looks like JSON text, but I have tried many ways to convert it to an object but failed. I tried to output it separately by each "" category but couldn't  
Can you help me

 ![123321](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/4/c419aaaa18330b108d60fa24c60a65bd4fd603ca.png)

I forgot to upload my work content

```auto
[{"id":"ac980724.3f2b2","type":"tab","label":"流程 1","disabled":false,"info":""},{"id":"1dad182f.f500f","type":"tcp in","z":"ac980724.3f2b2","name":"","server":"server","host":"","port":"6001","datamode":"stream","datatype":"buffer","newline":"","topic":"","base64":false,"x":120,"y":220,"wires":[["fec1f053.4706f"]]},{"id":"1c8943f7.9767dc","type":"switch","z":"ac980724.3f2b2","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"relay1","vt":"str"},{"t":"eq","v":"relay2","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":670,"y":340,"wires":[["5deab8c3.ec80e"],["6d14aec.ab3d35"]]},{"id":"27460140.bc5386","type":"debug","z":"ac980724.3f2b2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":870,"y":400,"wires":[]},{"id":"fec1f053.4706f","type":"debug","z":"ac980724.3f2b2","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":310,"y":220,"wires":[]},{"id":"35bfe847.cfcd98","type":"debug","z":"ac980724.3f2b2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":490,"y":340,"wires":[]},{"id":"1f9b4327.f9cccd","type":"split","z":"ac980724.3f2b2","name":"","splt":",","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":470,"y":400,"wires":[["27460140.bc5386","1c8943f7.9767dc"]]},{"id":"30a7c936.cad01e","type":"inject","z":"ac980724.3f2b2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[123,34,102,97,110,45,86,34,58,49,50,46,51,57,57,57,44,34,108,111,97,100,45,86,34,58,49,50,46,49,44,34,114,101,108,97,121,50,34,58,49,44,34,102,97,110,45,65,34,58,48,44,34,115,111,108,111,97,114,45,65,34,58,48,44,34,114,101,108,97,121,52,34,58,48,44,34,114,101,108,97,121,49,34,58,49,44,34,114,101,108,97,121,51,34,58,48,44,34,115,111,108,111,97,114,45,86,34,58,48,44,34,114,101,108,97,121,53,34,58,48,125]","payloadType":"bin","x":290,"y":400,"wires":[["1f9b4327.f9cccd","35bfe847.cfcd98"]]},{"id":"5deab8c3.ec80e","type":"debug","z":"ac980724.3f2b2","name":"relay1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":840,"y":280,"wires":[]},{"id":"6d14aec.ab3d35","type":"debug","z":"ac980724.3f2b2","name":"relay2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":830,"y":340,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [25 November 2021 11:24 UTC](https://discourse.nodered.org/t/im-trying-to-use-split-to-separate-the-content-but-it-doesnt-meet-my-needs/54264/2 "2021-11-25T11:24:03Z")

</div>

Have you tried the JSON node? That will parse the JSON string and convert it a JavaScript object you can use to access the properties of.

---

<div class="post-metadata">

**Author:** ![Cybertron](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cybertron/32/14683_2.png) [@Cybertron](https://discourse.nodered.org/u/Cybertron)\
**Post date:** [25 November 2021 11:28 UTC](https://discourse.nodered.org/t/im-trying-to-use-split-to-separate-the-content-but-it-doesnt-meet-my-needs/54264/3 "2021-11-25T11:28:16Z")

</div>

I tried the JSON node but it output the same output or Ignore payloads that are not in object format

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [25 November 2021 11:32 UTC](https://discourse.nodered.org/t/im-trying-to-use-split-to-separate-the-content-but-it-doesnt-meet-my-needs/54264/4 "2021-11-25T11:32:44Z")

</div>

Try

```auto
[{"id":"30a7c936.cad01e","type":"inject","z":"ac980724.3f2b2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[123,34,102,97,110,45,86,34,58,49,50,46,51,57,57,57,44,34,108,111,97,100,45,86,34,58,49,50,46,49,44,34,114,101,108,97,121,50,34,58,49,44,34,102,97,110,45,65,34,58,48,44,34,115,111,108,111,97,114,45,65,34,58,48,44,34,114,101,108,97,121,52,34,58,48,44,34,114,101,108,97,121,49,34,58,49,44,34,114,101,108,97,121,51,34,58,48,44,34,115,111,108,111,97,114,45,86,34,58,48,44,34,114,101,108,97,121,53,34,58,48,125]","payloadType":"bin","x":290,"y":400,"wires":[["f25dbb66.7bd728"]]},{"id":"f25dbb66.7bd728","type":"function","z":"ac980724.3f2b2","name":"","func":"msg.payload = JSON.parse(msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":310,"y":340,"wires":[["35bfe847.cfcd98"]]},{"id":"35bfe847.cfcd98","type":"debug","z":"ac980724.3f2b2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":370,"y":300,"wires":[]}]

```

```auto
msg.payload = JSON.parse(msg.payload);
return msg;

```

---

<div class="post-metadata">

**Author:** ![Cybertron](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cybertron/32/14683_2.png) [@Cybertron](https://discourse.nodered.org/u/Cybertron)\
**Post date:** [25 November 2021 11:34 UTC](https://discourse.nodered.org/t/im-trying-to-use-split-to-separate-the-content-but-it-doesnt-meet-my-needs/54264/5 "2021-11-25T11:34:42Z")

</div>

Oh, my God, this is perfect  
Why didn't I think of using this method, thank you very much

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [25 November 2021 11:36 UTC](https://discourse.nodered.org/t/im-trying-to-use-split-to-separate-the-content-but-it-doesnt-meet-my-needs/54264/6 "2021-11-25T11:36:56Z")

</div>

The issue with the JSON node is you have a Buffer object, not a JSON string - and the JSON node doesn't know what to do with it.

We should look at handling that better.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [9 December 2021 11:37 UTC](https://discourse.nodered.org/t/im-trying-to-use-split-to-separate-the-content-but-it-doesnt-meet-my-needs/54264/7 "2021-12-09T11:37:13Z")

</div>

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