# Json string to items

**URL:** <https://community.n8n.io/t/json-string-to-items/18667>\
**Category:** Questions\
**Created:** [October 13, 2022, 10:01pm UTC](https://community.n8n.io/t/json-string-to-items/18667 "2022-10-13T22:01:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![maartend](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/maartend/32/13312_2.png) [@maartend](https://community.n8n.io/u/maartend)\
**Post date:** [October 13, 2022, 10:01pm UTC](https://community.n8n.io/t/json-string-to-items/18667/1 "2022-10-13T22:01:36Z")

</div>

Hello all,

Through a soap API call, I am requesting an XML file that I have managed to turn into a json string, and that I would like to split into separate items. Now I need a field key name being one of the values.

The string looks like this:

```auto
[
  {
    "propertyName": {
      "BREAKFAST": {
        "DESCRIPTION": "Breakfast",
        "NETTTOTAL": "410.5900",
        "TAXTOTAL": "36.9100",
        "GROSSTOTAL": "447.5000"
      },
      "GOLF_BEER": {
        "DESCRIPTION": "Golf Beer",
        "NETTTOTAL": "142.1100",
        "TAXTOTAL": "12.7900",
        "GROSSTOTAL": "154.9000"
      },
      "GOLF_CT": {
        "DESCRIPTION": "Golf Coffee/Tea",
        "NETTTOTAL": "368.3300",
        "TAXTOTAL": "33.0700",
        "GROSSTOTAL": "401.4000"
      },
      "GOLF_FOOD": {
        "DESCRIPTION": "Golf Food",
        "NETTTOTAL": "392.6500",
        "TAXTOTAL": "35.3500",
        "GROSSTOTAL": "428.0000"
      },
      "GOLF_LIQ": {
        "DESCRIPTION": "Golf Liquor",
        "NETTTOTAL": "0.0000",
        "TAXTOTAL": "0.0000",
        "GROSSTOTAL": "0.0000"
      },
      "GOLF_SODA": {
        "DESCRIPTION": "Golf Soda",
        "NETTTOTAL": "112.8700",
        "TAXTOTAL": "10.1300",
        "GROSSTOTAL": "123.0000"
      },
      "GOLF_WINE": {
        "DESCRIPTION": "Golf Wine",
        "NETTTOTAL": "127.3900",
        "TAXTOTAL": "26.7100",
        "GROSSTOTAL": "154.1000"
      }
    }
  }
]

```

I would like to turn this into separate items, that would look like this:  
GOLF\_BEER | Golf Beer | 142.1100 | 12.7900 | 154.9000  
GOLF\_CT | Golf Coffee/Tea | 368.3300 | 33.0700 | 401.4000

(these would be records 2 and 3 from the example string above). So 5 fields in each record.

I think I would need a function node to achieve something like this, but I wish I was _that_ good with coding 😉

Would there be someone able to help me out?

Thanks! - Maarten

---

<div class="post-metadata">

**Author:** ![BramKn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bramkn/32/11894_2.png) [@BramKn](https://community.n8n.io/u/BramKn)\
**Post date:** [October 14, 2022, 6:39am UTC](https://community.n8n.io/t/json-string-to-items/18667/2 "2022-10-14T06:39:39Z")

</div>

Hi @maartend

You can also do it with 2 set nodes.  
Added both options below. I assumed you had an item per string. If not you also need another split infront with \n

---

<div class="post-metadata">

**Author:** ![maartend](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/maartend/32/13312_2.png) [@maartend](https://community.n8n.io/u/maartend)\
**Post date:** [October 14, 2022, 7:35am UTC](https://community.n8n.io/t/json-string-to-items/18667/3 "2022-10-14T07:35:13Z")

</div>

Hi Bram,

thanks for your reaction. If I read the function node correctly, this would change the data:

“GOLF\_BEER | Golf Beer | 142.1100 | 12.7900 | 154.9000”

into this format:

“GOLF\_BEER”: {  
“DESCRIPTION”: “Golf Beer”,  
“NETTTOTAL”: “142.1100”,  
“TAXTOTAL”: “12.7900”,  
“GROSSTOTAL”: “154.9000”

Is that correct? I actually need to go the other way. So this last format is my input, and I would need to change that into a table format with individual records, and 5 fields so that I can then load it into a database.

Would you have some magic code for that too?

Thanks! - Maarten

---

<div class="post-metadata">

**Author:** ![maartend](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/maartend/32/13312_2.png) [@maartend](https://community.n8n.io/u/maartend)\
**Post date:** [October 14, 2022, 7:37am UTC](https://community.n8n.io/t/json-string-to-items/18667/4 "2022-10-14T07:37:56Z")

</div>

Happy to do a quick call for some more explanation if needed 😉

---

<div class="post-metadata">

**Author:** ![BramKn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bramkn/32/11894_2.png) [@BramKn](https://community.n8n.io/u/BramKn)\
**Post date:** [October 14, 2022, 7:47am UTC](https://community.n8n.io/t/json-string-to-items/18667/5 "2022-10-14T07:47:14Z")

</div>

sure, invite me and I will join in a bit 😉

---

<div class="post-metadata">

**Author:** ![BramKn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bramkn/32/11894_2.png) [@BramKn](https://community.n8n.io/u/BramKn)\
**Post date:** [October 14, 2022, 8:44am UTC](https://community.n8n.io/t/json-string-to-items/18667/6 "2022-10-14T08:44:50Z")

</div>

HI @maartend

Don’t forget to set it as solved. 😉

---

<div class="post-metadata">

**Author:** ![maartend](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/maartend/32/13312_2.png) [@maartend](https://community.n8n.io/u/maartend)\
**Post date:** [October 14, 2022, 12:05pm UTC](https://community.n8n.io/t/json-string-to-items/18667/7 "2022-10-14T12:05:00Z")

</div>

Thanks for helping me out @BramKn , great work! 👍
