# Splitting Values from JSON

**URL:** <https://community.n8n.io/t/splitting-values-from-json/23013>\
**Category:** Questions\
**Tags:** data-transformation, transform-string\
**Created:** [February 14, 2023, 11:27am UTC](https://community.n8n.io/t/splitting-values-from-json/23013 "2023-02-14T11:27:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbuk](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mbuk](https://community.n8n.io/u/mbuk)\
**Post date:** [February 14, 2023, 11:27am UTC](https://community.n8n.io/t/splitting-values-from-json/23013/1 "2023-02-14T11:27:04Z")

</div>

Hi guys

I’ve scoured the forums for a solution to this and whilst I see lots of topics in relation to JSON, I can’t seem to find a solution that works for me - and I’m sure this should be straight forward with a regex type solution.

The JSON I need to extract the value from always follows the same structure:  
{“ZbBind”:{“Device”:“0x1035”,“Status”:0,“StatusMessage”:“SUCCESS”}}

The only value I need to extract is the Device value, so 0X1035 in the above example.  
Thanks all

## Information on your n8n setup

Version 0.204.0  
Self hosted on Digital Ocean Docker

---

<div class="post-metadata">

**Author:** ![Niklas\_Hatje](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/niklas_hatje/32/155398_2.png) [@Niklas\_Hatje](https://community.n8n.io/u/Niklas_Hatje)\
**Post date:** [February 14, 2023, 11:36am UTC](https://community.n8n.io/t/splitting-values-from-json/23013/2 "2023-02-14T11:36:12Z")

</div>

Hi @mbuk, based on what you describe it seems like the `Set node` is the right fit for you. You can see an example below:

---

<div class="post-metadata">

**Author:** ![mbuk](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mbuk](https://community.n8n.io/u/mbuk)\
**Post date:** [February 14, 2023, 11:45am UTC](https://community.n8n.io/t/splitting-values-from-json/23013/3 "2023-02-14T11:45:10Z")

</div>

Hi  
I’ve done as you describe but don’t get any results?

````auto
{
  "meta": {
    "instanceId": "13430cc8c4746822491278321fb5cf32374e1ff4e5e8ac13c3a1df5b155a52a5"
  },
  "nodes": [
    {
      "parameters": {
        "values": {
          "string": [
            {
              "value": "{\"ZbBind\":{\"Device\":\"0x1035\",\"Status\":0,\"StatusMessage\":\"SUCCESS\"}}"
            }
          ]
        },
        "options": {}
      },
      "id": "26c8c48a-3cd0-45d6-a725-58ab0dfe820e",
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        880,
        180
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "number": [
            {
              "name": "deviceValue",
              "value": "={{ $json.ZbBind.Device }}"
            }
          ]
        },
        "options": {}
      },
      "id": "47b23700-e16c-4ec5-b57e-ee3604c6e845",
      "name": "Set1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1100,
        180
      ]
    }
  ],
  "connections": {
    "Set": {
      "main": [
        [
          {
            "node": "Set1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}```
````

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [February 16, 2023, 10:55am UTC](https://community.n8n.io/t/splitting-values-from-json/23013/4 "2023-02-16T10:55:14Z")

</div>

Hi @mbuk, it looks in your example you aren’t working with a JSON object but a string inside a `propertyName` field. For @Niklas_Hatje’s logic to work you’d first need to parse this string. You can use [JSON.parse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) for the job.

I’ve updated your example workflow to show the idea:

This is the result:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/5/5/55a8e9359f9615074b9f155359de1bf385dd87dc.png)

Hope this helps!

---

<div class="post-metadata">

**Author:** ![mbuk](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mbuk](https://community.n8n.io/u/mbuk)\
**Post date:** [February 16, 2023, 12:14pm UTC](https://community.n8n.io/t/splitting-values-from-json/23013/5 "2023-02-16T12:14:03Z")

</div>

Hi

That’s great - thank you. Your solution worked, however when I tried to replicate it in my own workflow, the final set module couldn’t find a value from the previous input.

It wasn’t until a bit of trial and error that I noticed when pasting the JSON into the set module, my version was using a different quotation character:

Mine:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/e/8/e8927ae5821f4edd5a0a863f8dce4186deb73943.png)

Yours:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/b/8/b8fc4ebde23e445602f463cbc40b9508cf7b3705.png)

It’s a subtle difference but enough for the workflow to not recognise the input!.

Thanks for your help here - really do appreciate it.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [February 23, 2023, 12:14pm UTC](https://community.n8n.io/t/splitting-values-from-json/23013/6 "2023-02-23T12:14:33Z")

</div>

Closed on February 23, 2023, 12:14pm UTC

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