# Help with helping someone - splitting JSON objects

**URL:** <https://discourse.nodered.org/t/help-with-helping-someone-splitting-json-objects/30229>\
**Category:** General\
**Created:** [16 July 2020 21:36 UTC](https://discourse.nodered.org/t/help-with-helping-someone-splitting-json-objects/30229 "2020-07-16T21:36:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [16 July 2020 21:36 UTC](https://discourse.nodered.org/t/help-with-helping-someone-splitting-json-objects/30229/1 "2020-07-16T21:36:31Z")

</div>

I am helping someone and I am asking here for help. Not because I want the glory of being _the one who did it_ but more to not confuse the person with a lot of people giving their thoughts.  
(No offence)

I am not exactly getting it, and may have actually done what they need doing now anyway.  
But for the sake of keeping options open, I'm asking.

This is a cut down message.

```auto
{"topic":"ATESTEO/Wolfsburg/W16","payload":{"MQTTWert1":"25.1","MQTTWert1name":"T_BoxenLuft","MQTTWert2":"-101","MQTTWert2name":"N_EMA_VL","MQTTWert3":"932","MQTTWert3name":"n_Antrieb","MQTTWert4":"269","MQTTWert4name":"M_Antrieb","Status":"Läuft"},"qos":1,"retain":false,"_topic":"ATESTEO/Wolfsburg/W16","_msgid":"3f4512b0.dc5bee","kColor":"black","vColor":"black","template":"<html>\n<head>\n<style>\ntable.FixedTable\n{\n table-layout: fixed;\n border: 0;\n}\n</style> \n</head>\n<body>\n<table class=\"FixedTable\">\n <tbody>\n <tr ng-repeat=\"(k,v) in msg.payload\" ng-if=\"k != 'Item'\">\n <td style=\"width: 250; color:{{msg.kColor}}\">{{k}}</td>\n <td style=\"text-align:justify; color:{{msg.vColor}}\">{{v}}</td>\n </tr>\n </tbody>\n</table>\n</body>\n</html>","color":"lime"}

```

The `payload` is ..... the part of interest to _split_.  
There are other things which are claimed are needed. Shrug. Dunno. I can't see how/why as the data is ultimately going to a `chart` node.

The `payload` has two lines. A name and a value.  
It would be nice to split this up so there are (in this case) 4 messages sent out.  
Each with a `topic` of what the name is and a `payload` of what the value is, and the other stuff which is in the bigger message as themselves.

Yes, this may be futile and the problem is already solved by what I did. But I'm not that arrogant to think I have found the answer this quickly / easily.

Someone - please.

---

<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:** [16 July 2020 21:53 UTC](https://discourse.nodered.org/t/help-with-helping-someone-splitting-json-objects/30229/2 "2020-07-16T21:53:25Z")

</div>

Use a `Split` node, with the `Copy key to...` option enabled and configured to set `msg.topic`:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/6/36375b72d0c16bd97e82cf11a0a29745e3312cac.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [16 July 2020 22:02 UTC](https://discourse.nodered.org/t/help-with-helping-someone-splitting-json-objects/30229/4 "2020-07-16T22:02:48Z")

</div>

Ok, (second attempt) but I am getting:  
`Invalid split property: Error: invalid array split length: `

I think the `split using` part is not set correctly. I left the default `\n` in there. I'm guessing I need to delete it too?

Ok, **length**. But the message part lengths are not fixed as far as I know/see.

---

<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:** [16 July 2020 22:05 UTC](https://discourse.nodered.org/t/help-with-helping-someone-splitting-json-objects/30229/5 "2020-07-16T22:05:53Z")

</div>

It depends on the data you are passing it.

The example message you shared has `msg.payload` as an Object. So you can ignore the 'String' and 'Array' options in the Split node and focus on the Object options as I suggested.

Leave all the options in the Split node to their default value, apart from the Copy key option I highlighted.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [16 July 2020 22:09 UTC](https://discourse.nodered.org/t/help-with-helping-someone-splitting-json-objects/30229/6 "2020-07-16T22:09:51Z")

</div>

Sorry. Only about 60 minutes out of bed.

That looks interesting/promising for things.

---

<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:** [30 July 2020 22:09 UTC](https://discourse.nodered.org/t/help-with-helping-someone-splitting-json-objects/30229/7 "2020-07-30T22:09:51Z")

</div>

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