# NodeOperationError: The 'JSON Output' in item 0 contains invalid JSON

**URL:** <https://community.n8n.io/t/nodeoperationerror-the-json-output-in-item-0-contains-invalid-json/57256>\
**Category:** Questions\
**Created:** [October 10, 2024, 8:06pm UTC](https://community.n8n.io/t/nodeoperationerror-the-json-output-in-item-0-contains-invalid-json/57256 "2024-10-10T20:06:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephen\_Parkes](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/stephen_parkes/32/46213_2.png) [@Stephen\_Parkes](https://community.n8n.io/u/Stephen_Parkes)\
**Post date:** [October 10, 2024, 8:06pm UTC](https://community.n8n.io/t/nodeoperationerror-the-json-output-in-item-0-contains-invalid-json/57256/1 "2024-10-10T20:06:09Z")

</div>

Hi all, always awkward when your first post is asking a question 😉

Is there any problem with long strings in JSON objects?

I’m using an edit fields node to format a JSON object that will be used in a HTTP request in the following node but I always get the error listed in the topic title despite the output parsing as valid JSON (all standards) in linters.

the node is listed below (hopefully)

if the {{ $json.data.quote()}} is replaced with a string the node works. When it has the output of the previous node (just a really long string but escaped because it contains " marks) it doesn’t work despite the output still parsing as valid outside of n8n.

## Information on your n8n setup

- 1.61.0
- SQLite
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):**
- running in Docker
- Linux Ubuntu 22.02 LTS on Oracle ARM VM

---

<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:** [October 10, 2024, 8:06pm UTC](https://community.n8n.io/t/nodeoperationerror-the-json-output-in-item-0-contains-invalid-json/57256/2 "2024-10-10T20:06: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:** ![ihortom](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ihortom/32/11473_2.png) [@ihortom](https://community.n8n.io/u/ihortom)\
**Post date:** [October 10, 2024, 8:39pm UTC](https://community.n8n.io/t/nodeoperationerror-the-json-output-in-item-0-contains-invalid-json/57256/3 "2024-10-10T20:39:27Z")

</div>

Welcome to the community @Stephen_Parkes !

> **Tip for sharing information**
>
> #### Pasting your n8n workflow
> 
> * * *
> 
> Ensure to copy your n8n workflow and paste it in the _code block_, that is in between the pairs of triple backticks, which also could be achieved by clicking `</>` (preformatted text) in the editor and pasting in your workflow.
> 
> ```  
> \<your workflow\>  
> ```
> 
> That implies to any JSON output you would like to share with us.
> 
> Make sure that you have removed any sensitive information from your workflow and include dummy or pinned data with it!
> 
> * * *

It depends on what kind of data type/structure the expression `$json.data.quote()` returns. You might want to try transforming _the whole JSON into an expression_. That is, try out this

```auto
{{ 
{
  "messages": [
    {
      "role": "system",
      "content": $json.data.quote()
    },
    {
      "role": "user",
      "content":"the index is $runIndex"
    }
  ],
  "model": "llama-3.2-90b-text-preview",
  "temperature": 1,
  "max_tokens": 8192,
  "top_p": 1,
  "stream": false,
  "response_format": {
    "type": "json_object"
  },
  "stop": null
}
}}

```

---

<div class="post-metadata">

**Author:** ![Stephen\_Parkes](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/stephen_parkes/32/46213_2.png) [@Stephen\_Parkes](https://community.n8n.io/u/Stephen_Parkes)\
**Post date:** [October 11, 2024, 6:24am UTC](https://community.n8n.io/t/nodeoperationerror-the-json-output-in-item-0-contains-invalid-json/57256/4 "2024-10-11T06:24:23Z")

</div>

$json.data.quote() is just a really long string. It shouldn’t matter unless quote() can return something that isn’t a string.

Interestingly I think this is a bug in the output window.

In the first version n8n said the JSON was wrong but the output was valid and this way around the output window says it’s valid but the output doesn’t validate having extra quote marks around the long quoted string but does pass good data to the next node.

Thanks for your help. I’ll see if I can create a minimal example and report it as a potential bug.

---

<div class="post-metadata">

**Author:** ![ihortom](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ihortom/32/11473_2.png) [@ihortom](https://community.n8n.io/u/ihortom)\
**Post date:** [October 11, 2024, 3:42pm UTC](https://community.n8n.io/t/nodeoperationerror-the-json-output-in-item-0-contains-invalid-json/57256/5 "2024-10-11T15:42:36Z")

</div>

> [@Stephen\_Parkes](#):
>
> $json.data.quote() is just a really long string. It shouldn’t matter unless quote() can return something that isn’t a string.

If the string includes new lines or un-escaped quotes it can break JSON.

---

<div class="post-metadata">

**Author:** ![Stephen\_Parkes](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/stephen_parkes/32/46213_2.png) [@Stephen\_Parkes](https://community.n8n.io/u/Stephen_Parkes)\
**Post date:** [October 11, 2024, 3:59pm UTC](https://community.n8n.io/t/nodeoperationerror-the-json-output-in-item-0-contains-invalid-json/57256/6 "2024-10-11T15:59:20Z")

</div>

The string doesn’t contain either. n8n thinks it’s not valid but cutting and pasting the result shows it passes RFC8259, RFC7159, RFC4627 and EMCA-404.

I’m a bit short on spoons tonight after a tough week returning to work after a few days off with the flu. If I can find the time I’ll try and reproduce with a minimal workflow to show that n8n suggests valid JSON isn’t correct and invalid JSON is correct. If I can find that then if it is an issue it should be easy to track down.

---

<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:** [January 9, 2025, 3:59pm UTC](https://community.n8n.io/t/nodeoperationerror-the-json-output-in-item-0-contains-invalid-json/57256/7 "2025-01-09T15:59:33Z")

</div>

Closed on January 9, 2025, 3:59pm UTC

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