# Trying to disect a payload object and combine parts into msg.options

**URL:** https://discourse.nodered.org/t/trying-to-disect-a-payload-object-and-combine-parts-into-msg-options/73069
**Category:** General
**Created:** [2 January 2023 15:39 UTC](https://discourse.nodered.org/t/trying-to-disect-a-payload-object-and-combine-parts-into-msg-options/73069 "2023-01-02T15:39:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Mikee1234K](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikee1234k/32/70283_2.png) [@Mikee1234K](https://discourse.nodered.org/u/Mikee1234K)
#### Post date: [2 January 2023 15:39 UTC](https://discourse.nodered.org/t/trying-to-disect-a-payload-object-and-combine-parts-into-msg-options/73069/1 "2023-01-02T15:39:07Z")

</div>

I am querying a Sonos node to get my saved favourite radio stations to send to a dashboard dropdown node. From what I have researched, I should be sending it as a msg.options object.  
I have located the parts of where my radio stations are stored.  
They are stored in payload[0].title, payload[1].title etc. One of the (many) problems is I do not know how long the array is. I can see a number on the debug node but cannot find a corresponding value in the message. I have experimented with substringafter and substringbefore, that did not work. I also experimented with the split node and the string node. FAIL.  
I guess that somehow I have to use a function node to read the array, store it, then send as msg.options  
Marked here is the array length (but cannot find that number in the message) and one of the stations I need  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/4/a4803e7334674f2db4c3361860a6ffa63676ce4e.png)

This is the whole debug message:

```auto
{"_msgid":"788ab445d2d20e3e","payload":[{"id":"FV:2/10","title":"Capital DANCE","artist":"","album":"","description":"Sonos Radio Station","uri":"x-sonosapi-stream:tunein%3a153035?sid=303&amp;flags=8224&amp;sn=1","artUri":"https://sali.sonos.radio/image?w=60&amp;image=https%3A%2F%2Fcdn-profiles.tunein.com%2Fs309497%2Fimages%2Flogog.jpg%3Ft%3D2&amp;partnerId=tunein","metadata":"&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;10092020tunein%3a153035&quot; parentID=&quot;00020000station:dance&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;Capital DANCE&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON77575_&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;","sid":"303","serviceName":"Sonos Radio","upnpClass":"object.item.audioItem.audioBroadcast","processingType":"stream"},{"id":"FV:2/9","title":"Heart Dance","artist":"","album":"","description":"Sonos Radio Station","uri":"x-sonosapi-stream:tunein%3a95904?sid=303&amp;flags=8224&amp;sn=1","artUri":"https://sali.sonos.radio/image?w=60&amp;image=https%3A%2F%2Fcdn-profiles.tunein.com%2Fs306293%2Fimages%2Flogog.jpg%3Ft%3D156104&amp;partnerId=tunein","metadata":"&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;10092020tunein%3a95904&quot; parentID=&quot;00020000station:dance&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;Heart Dance&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON77575_&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;","sid":"303","serviceName":"Sonos Radio","upnpClass":"object.item.audioItem.audioBroadcast","processingType":"stream"},{"id":"FV:2/3","title":"Heart Essex","artist":"","album":"","description":"Sonos Radio Station","uri":"x-sonosapi-stream:global%3a99524?sid=303&amp;flags=8224&amp;sn=1","artUri":"https://sali.sonos.radio/image?w=60&amp;image=https%3A%2F%2Fherald.musicradio.com%2Fmedia%2F9357ca3a-3ec2-4114-8c45-c2391bc418f4.png&amp;partnerId=global","metadata":"&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;10092020global%3a99524&quot; parentID=&quot;00020000station:heart essex&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;Heart Essex&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON77575_&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;","sid":"303","serviceName":"Sonos Radio","upnpClass":"object.item.audioItem.audioBroadcast","processingType":"stream"},{"id":"FV:2/0","title":"Hit List","artist":"","album":"","description":"Sonos Radio Station","uri":"x-sonosapi-radio:sonos%3a2997?sid=303&amp;flags=8224&amp;sn=1","artUri":"https://sonosradio.imgix.net/placeholders/a78b8e1eb3318dd09f0bb529deed153d_09.png?w=200&amp;auto=format,compress","metadata":"&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;100c2020sonos%3a2997&quot; parentID=&quot;00080004%2fstations%2fen-US%2fUK%2fc2Q6VUs6cG9wLWhpdHM&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;Hit List&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast.#list-genre&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON77575_&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;","sid":"303","serviceName":"Sonos Radio","upnpClass":"object.item.audioItem.audioBroadcast.#list-genre","processingType":"stream"},{"id":"FV:2/8","title":"KISS","artist":"","album":"","description":"Planet Radio Station","uri":"x-sonosapi-stream:pru_svc_ki1?sid=320&amp;flags=32&amp;sn=3","artUri":"http://dtu8ldmaopof3.cloudfront.net/i/b64aHR0cHM6Ly9tZWRpYS5iYXVlcnJhZGlvLmNvbS9pbWFnZS91cGxvYWQvY19jcm9wLGdfY3VzdG9tL3YxNjE4MzE1MDI5L2JyYW5kX21hbmFnZXIvc3RhdGlvbnMvYWNpMmxqaDZ0cHpwdGJ2aXpmeGkucG5n_300.jpg","metadata":"&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;10090020pru_svc_ki1&quot; parentID=&quot;10fe00c4pru_stations&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;KISS&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON81927_X_#Svc81927-0-Token&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;","sid":"320","serviceName":"","upnpClass":"object.item.audioItem.audioBroadcast","processingType":"stream"},{"id":"FV:2/7","title":"KISS DANCE","artist":"","album":"","description":"Planet Radio Station","uri":"x-sonosapi-stream:pru_svc_ki5?sid=320&amp;flags=32&amp;sn=3","artUri":"http://dtu8ldmaopof3.cloudfront.net/i/b64aHR0cHM6Ly9tZWRpYS5iYXVlcnJhZGlvLmNvbS9pbWFnZS91cGxvYWQvY19jcm9wLGdfY3VzdG9tL3YxNjYxMjUyMjkzL2JyYW5kX21hbmFnZXIvc3RhdGlvbnMvcnJ0ZnU2YnBucHZoa3NrNDU5a2suanBn_300.jpg","metadata":"&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;10090020pru_svc_ki5&quot; parentID=&quot;10fe00c4pru_stations&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;KISS DANCE&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON81927_X_#Svc81927-0-Token&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;","sid":"320","serviceName":"","upnpClass":"object.item.audioItem.audioBroadcast","processingType":"stream"},{"id":"FV:2/1","title":"Main Stream","artist":"","album":"","description":"Sonos Radio Station","uri":"x-sonosapi-radio:sonos%3a3014?sid=303&amp;flags=8224&amp;sn=1","artUri":"https://sonosradio.imgix.net/placeholders/04ecd6eaa694770d0d468e371d7ecf50_09.png?w=200&amp;auto=format,compress","metadata":"&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;100c2020sonos%3a3014&quot; parentID=&quot;00080004%2fstations%2fen-US%2fUK%2fc2Q6VUs6cG9wLWhpdHM&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;Main Stream&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast.#list-genre&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON77575_&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;","sid":"303","serviceName":"Sonos Radio","upnpClass":"object.item.audioItem.audioBroadcast.#list-genre","processingType":"stream"},{"id":"FV:2/5","title":"Radio 1","artist":"","album":"","description":"BBC Sounds Station","uri":"x-sonosapi-hls:stations%7eplayable%7e%7ebbc_radio_one%7e%7eurn%3abbc%3aradio%3anetwork%3abbc_radio_one?sid=325&amp;flags=288&amp;sn=2","artUri":"https://sounds.files.bbci.co.uk/3.4.2/networks/bbc_radio_one/colour_450x450.png","metadata":"&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;10090120stations%7eplayable%7e%7ebbc_radio_one%7e%7eurn%3abbc%3aradio%3anetwork%3abbc_radio_one&quot; parentID=&quot;00080000experience%7emodule%7e%7elisten_live%7e%7e&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;Radio 1&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON83207_X_#Svc83207-0-Token&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;","sid":"325","serviceName":"","upnpClass":"object.item.audioItem.audioBroadcast","processingType":"stream"},{"id":"FV:2/6","title":"Radio 1 Dance","artist":"","album":"","description":"BBC Sounds Station","uri":"x-sonosapi-hls:stations%7eplayable%7e%7ebbc_radio_one_dance%7e%7eurn%3abbc%3aradio%3anetwork%3abbc_radio_one_dance?sid=325&amp;flags=288&amp;sn=2","artUri":"https://sounds.files.bbci.co.uk/3.4.2/networks/bbc_radio_one_dance/colour_450x450.png","metadata":"&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;10090120stations%7eplayable%7e%7ebbc_radio_one_dance%7e%7eurn%3abbc%3aradio%3anetwork%3abbc_radio_one_dance&quot; parentID=&quot;00080000experience%7emodule%7e%7elisten_live%7e%7e&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;Radio 1 Dance&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON83207_X_#Svc83207-0-Token&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;","sid":"325","serviceName":"","upnpClass":"object.item.audioItem.audioBroadcast","processingType":"stream"},{"id":"FV:2/4","title":"Radio Essex","artist":"","album":"","description":"Sonos Radio Station","uri":"x-sonosapi-stream:tunein%3a18768?sid=303&amp;flags=8224&amp;sn=1","artUri":"https://sali.sonos.radio/image?w=60&amp;image=https%3A%2F%2Fcdn-radiotime-logos.tunein.com%2Fs86688g.png&amp;partnerId=tunein","metadata":"&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;10092020tunein%3a18768&quot; parentID=&quot;00020000station:radio essex&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;Radio Essex&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON77575_&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;","sid":"303","serviceName":"Sonos Radio","upnpClass":"object.item.audioItem.audioBroadcast","processingType":"stream"},{"id":"FV:2/2","title":"Shake It Off","artist":"","album":"","description":"Sonos Radio Station","uri":"x-sonosapi-radio:sonos%3a155571?sid=303&amp;flags=8224&amp;sn=1","artUri":"https://sonosradio.imgix.net/station-images/c10db51e-0a6c-4cd6-98ec-00b31c1636f5.png?w=200&amp;auto=format,compress","metadata":"&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;100c2020sonos%3a155571&quot; parentID=&quot;00080004%2fstations%2fen-US%2fUK%2fc2Q6VUs6cG9wLWhpdHM&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;Shake It Off&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast.#list-genre&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON77575_&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;","sid":"303","serviceName":"Sonos Radio","upnpClass":"object.item.audioItem.audioBroadcast.#list-genre","processingType":"stream"}]}

```

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [2 January 2023 15:54 UTC](https://discourse.nodered.org/t/trying-to-disect-a-payload-object-and-combine-parts-into-msg-options/73069/2 "2023-01-02T15:54:05Z")

</div>

You could use a change node with a jsonata expression:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/0/40e988b945a4dce4fc386080a0fffbd57a97b13f.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/4/34d08c526fad2f920fbff56202a67079fd003ae4.png)

Not sure why you need to know the length of the array.  
Keep in mind that the idea of node-red is "low-code", jsonata is quite powerful for these types of operations.

---

<div class="post-metadata">

### Author: ![Mikee1234K](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikee1234k/32/70283_2.png) [@Mikee1234K](https://discourse.nodered.org/u/Mikee1234K)
#### Post date: [2 January 2023 16:00 UTC](https://discourse.nodered.org/t/trying-to-disect-a-payload-object-and-combine-parts-into-msg-options/73069/3 "2023-01-02T16:00:48Z")

</div>

😂 I was properly overthinking this one. Creating problems where there arent any... I didnt think jsonata would parse the whole object.

---

<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: [3 March 2023 16:00 UTC](https://discourse.nodered.org/t/trying-to-disect-a-payload-object-and-combine-parts-into-msg-options/73069/4 "2023-03-03T16:00:50Z")

</div>

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