# Extract data from a JSON received from a webhook

**URL:** <https://community.n8n.io/t/extract-data-from-a-json-received-from-a-webhook/67887>\
**Category:** Questions\
**Created:** [27. Dezember 2024 um 13:21 UTC](https://community.n8n.io/t/extract-data-from-a-json-received-from-a-webhook/67887 "2024-12-27T13:21:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![agencia\_numuu\_numuu](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/agencia_numuu_numuu/32/52166_2.png) [@agencia\_numuu\_numuu](https://community.n8n.io/u/agencia_numuu_numuu)\
**Post date:** [27. Dezember 2024 um 13:21 UTC](https://community.n8n.io/t/extract-data-from-a-json-received-from-a-webhook/67887/1 "2024-12-27T13:21:10Z")

</div>

I am having trouble extracting data from the JSON below:

[  
{  
“headers”: {…com.br",  
“user-agent”: “python-requests/2.31.0”,  
“content-length”: “725”,  
“accept”: “_/_”,  
“accept-encoding”: “gzip, deflate”,  
“content-type”: “application/json”,  
“x-forwarded-for”: “19…41”,  
“x-forwarded-host”: “…com.br”,  
“x-forwarded-proto”: “https”  
},  
“params”: {},  
“query”: {},  
“body”: [  
{  
“orcamento\_informado”: “cpf\_cliente”,  
“nome\_cliente”: “nome\_cliente”,  
“cpf\_cliente”: “numero do cpf”,  
“telefone\_cliente”: 4198…7,  
“contact:”: {  
“name”: “nome sistema - teste”,  
“number”: “554…0317”  
},  
“company”: {  
“name”: “Nome empresa - sistema”,  
“id”: “e84f1191…95”  
},  
“ticket”: {  
“id”: 489…23,  
“hash”: “E9413A6B166…9EF390D9137”,  
“fields”: [  
{  
“field”: “email”,  
“value”: “cemail”  
},  
{  
“field”: “campanha”,  
“value”: “camanha”  
},  
{  
“field”: “origem”,  
“value”: “cagem”  
},  
{  
“field”: “link\_crm”,  
“value”: “camnk”  
},  
{  
“field”: “regiao”,  
“value”: “camao”  
}  
],  
“tags”: [  
“TA”  
]  
}  
}  
],  
“webhookUrl”: “https://…”,  
“executionMode”: “test”  
}  
]

When trying to assign the values from the body to a SET node, the variables in the SET node receive NULL, even though the values are correctly coming from the WEBHOOK.

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

The strangest thing is that when I test it in edit mode, the flow works perfectly, but when we go to production, the values received in the webhook body are not recognized in the flow.

---

<div class="post-metadata">

**Author:** ![n8n](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/n8n/32/196425_2.png) [@n8n](https://community.n8n.io/u/n8n)\
**Post date:** [27. Dezember 2024 um 13:21 UTC](https://community.n8n.io/t/extract-data-from-a-json-received-from-a-webhook/67887/2 "2024-12-27T13:21:11Z")

</div>

It looks like your topic is missing some important information. Could you provide the following if applicable.

- **n8n version:**
- **Database (default: SQLite):**
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):**
- **Running n8n via (Docker, npm, n8n cloud, desktop app):**
- **Operating system:**

---

<div class="post-metadata">

**Author:** ![agencia\_numuu\_numuu](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/agencia_numuu_numuu/32/52166_2.png) [@agencia\_numuu\_numuu](https://community.n8n.io/u/agencia_numuu_numuu)\
**Post date:** [27. Dezember 2024 um 14:20 UTC](https://community.n8n.io/t/extract-data-from-a-json-received-from-a-webhook/67887/3 "2024-12-27T14:20:41Z")

</div>

Of course, sorry for my mistake

> [@n8n](#):
>
> - **n8n version: 1.48.3**
> - **Database (default: SQLite): SQLite**
> - **n8n EXECUTIONS\_PROCESS setting (default: own, main): ??**
> - **Running n8n via (Docker, npm, n8n cloud, desktop app): Docker**
> - **Operating system: Windows**

---

<div class="post-metadata">

**Author:** ![Ingo](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ingo/32/44460_2.png) [@Ingo](https://community.n8n.io/u/Ingo)\
**Post date:** [27. Dezember 2024 um 17:10 UTC](https://community.n8n.io/t/extract-data-from-a-json-received-from-a-webhook/67887/4 "2024-12-27T17:10:01Z")

</div>

Hi @agencia_numuu_numuu ,

your JSON above throws a lot of errors when fed into a validator. Have you made sure, you are working with proper syntax?

Best, Ingo

---

<div class="post-metadata">

**Author:** ![agencia\_numuu\_numuu](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/agencia_numuu_numuu/32/52166_2.png) [@agencia\_numuu\_numuu](https://community.n8n.io/u/agencia_numuu_numuu)\
**Post date:** [28. Dezember 2024 um 18:35 UTC](https://community.n8n.io/t/extract-data-from-a-json-received-from-a-webhook/67887/5 "2024-12-28T18:35:48Z")

</div>

This is the JSON that I’m receiving on my webhook. It is the JSON that the system that I’m integrating send from their api.

I just copied and pasted the JSON. I suppressed some of the variable values, but I believe it doesn’t affect the analysis here.

Follow the JSON again:

item  
[  
{  
“headers”:  
{  
“host”:  
“n8n.xxxxxxxxxx.com.br”,  
“user-agent”:  
“python-requests/2.31.0”,  
“content-length”:  
“617”,  
“accept”:  
“_/_”,  
“accept-encoding”:  
“gzip, deflate”,  
“content-type”:  
“application/json”,  
“x-forwarded-for”:  
“187.xxxxxx.70.xxxxxxx”,  
“x-forwarded-host”:  
“n8n.xxxxxxxxx.com.br”,  
“x-forwarded-proto”:  
“https”  
},  
“params”:  
{  
},  
“query”:  
{  
},  
“body”:  
{  
“cpf\_cliente”:  
“034.xxxxxxx.205-98”,  
“contact:”:  
{  
“name”:  
“xxxxxx Morais”,  
“number”:  
“5571xxxxxxxxx301”  
},  
“company”:  
{  
“name”:  
“Zoxxxxxxxxli”,  
“id”:  
“e84f11xxxxxxxxa319fa2e395”  
},  
“ticket”:  
{  
“id”:  
52357,  
“hash”:  
“9039812373xxxxxxxxxxxF6E214BB3”,  
“fields”:  
[  
{  
“field”:  
“email”,  
“value”:  
“[crisxxxxxxxxxxx@hotmail.com](mailto:crisxxxxxxxxxxx@hotmail.com)”  
},  
{  
“field”:  
“campanha”,  
“value”:  
“[LExxxxxxxxxxBR]”  
},  
{  
“field”:  
“origem”,  
“value”:  
“Busca Paga | Facebook Ads”  
},  
{  
“field”:  
“link\_crm”,  
“value”:  
“[https://crm.rxxxxxxxxxxxxxx0027359ff8?view=pipeline](https://crm.rxxxxxxxxxxxxxx0027359ff8?view=pipeline)”  
},  
{  
“field”:  
“regiao”,  
“value”:  
“Nordeste”  
}  
],  
“tags”:  
[  
“NORDESTE”,  
“interacao”  
]  
}  
},  
“webhookUrl”:  
“[https://n8n.xxxxxxxxx.com.br/webhook/3xxxxxxxxxxc9436](https://n8n.xxxxxxxxx.com.br/webhook/3xxxxxxxxxxc9436)”,  
“executionMode”:  
“production”  
}  
]

---

<div class="post-metadata">

**Author:** ![Ingo](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ingo/32/44460_2.png) [@Ingo](https://community.n8n.io/u/Ingo)\
**Post date:** [28. Dezember 2024 um 20:27 UTC](https://community.n8n.io/t/extract-data-from-a-json-received-from-a-webhook/67887/6 "2024-12-28T20:27:33Z")

</div>

Two observations:

- Your pasted JSON doesn’t show straight double quotes. If you’re working with JSON, make sure you’re using straight double quotes `"` to avoid syntax errors. My n8n instance could only process the JSON without errors after replacing all the double quotes accordingly. You might want to consider some data cleaning as an intermediate step, if this is what you are getting back from the API.
- Your screenshot shows a Split Out node before the Edit Fields node. Depending on what fields and how you split, this could also be responsible for generating items with lots unedfined values. You could share your workflow to clarify on that.

I have taken the (adjusted) JSON and sketched out two exemplary paths to further process the body data, one with Split Out, one with Edit Fields only. Let me know if it helps.

Cheers, Ingo

---

<div class="post-metadata">

**Author:** ![agencia\_numuu\_numuu](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/agencia_numuu_numuu/32/52166_2.png) [@agencia\_numuu\_numuu](https://community.n8n.io/u/agencia_numuu_numuu)\
**Post date:** [30. Dezember 2024 um 17:47 UTC](https://community.n8n.io/t/extract-data-from-a-json-received-from-a-webhook/67887/7 "2024-12-30T17:47:03Z")

</div>

I did exactly the same thing, and whem I try on test mode, it works, but when I put the flow in production, all the variables are read as Undefined in the nodes after the webhook.

---

<div class="post-metadata">

**Author:** ![agencia\_numuu\_numuu](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/agencia_numuu_numuu/32/52166_2.png) [@agencia\_numuu\_numuu](https://community.n8n.io/u/agencia_numuu_numuu)\
**Post date:** [30. Dezember 2024 um 17:51 UTC](https://community.n8n.io/t/extract-data-from-a-json-received-from-a-webhook/67887/8 "2024-12-30T17:51:00Z")

</div>

follow an example of an execution:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/1/1/1166d884fee87c55ab181b60ffa9ba9e8f791871.jpeg)

Note that in the node ‘split’ appears an issue, but the flow continues. After that in the node ‘SET’ all the information received from the webhook are missing

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/a/f/afe6c352b43b8f3855041ee4b14a6e9e6e1882be.png)

---

<div class="post-metadata">

**Author:** ![Ingo](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ingo/32/44460_2.png) [@Ingo](https://community.n8n.io/u/Ingo)\
**Post date:** [4. Januar 2025 um 12:09 UTC](https://community.n8n.io/t/extract-data-from-a-json-received-from-a-webhook/67887/9 "2025-01-04T12:09:47Z")

</div>

Hi @agencia_numuu_numuu ,

you should never ignore the first error message as everything else is likely a consequential error. 😅

The expression `{{ $json.body[0] }}` in your split node cannot work because the `body` object in your JSON is not an array. It is a standard object, not an array-like structure that can be accessed using an index like `[0]`. To access specific fields in the `body` object, you would use the dot (`.`) notation, depending on your requirements.

If you wanted to include, let’s say cpf\_cliente as in your example, you could address the field with a fixed string (see screenshot) or use the expression as such: {{ $json.body.cpf\_cliente }}

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

Cheers, Ingo
