The 'JSON Output' in item 0 contains invalid JSON in the Edit Fields Node

Hello n8n-Community!

Does anyone know what is causing the error in this code?

I’ve also tried everything with JSON.stringify(), but so far without success.

Problem width Error in the Edit Fields Node: The ‘JSON Output’ in item 0 contains invalid JSON

{
  "ltd-parts": [
    {
      "partID" : "{{ $json.objects[0].id }}",
      "partNumber" : "{{$json.objects[0].partNumber }}",
      "partName" : "{{ $json.objects[0].name }}",
      "partText" : "{{ $json.objects[0].text }}",
      "partPriceNetto" : "{{ $json.objects[0].priceNet }}",
      "partPriceBrutto" : "{{ $json.objects[0].priceGross }}",
      "partTax" : "{{ $json.objects[0].taxRate }}",
      "partUnityID" : "{{ $json.objects[0].unity.id }}"
    },
    {
      "partID" : "{{ $json.objects[1].id }}",
      "partNumber" : "{{$json.objects[1].partNumber }}",
      "partName" : "{{ $json.objects[1].name }}",
      "partText" : "{{ $json.objects[1].text }}",
      "partPriceNetto" : "{{ $json.objects[1].priceNet }}",
      "partPriceBrutto" : "{{ $json.objects[1].priceGross }}",
      "partTax" : "{{ $json.objects[1].taxRate }}",
      "partUnityID" : "{{ $json.objects[1].unity.id }}"
    }
  ]
}
{
  "ltd-parts": [
    {
      "partID" : "45043439",
      "partNumber" : "RT-MG-10000089",
      "partName" : ""Großunternehmen lebenslange Mitgliedschaft bei XYZ"",
      "partText" : ""Diese Großunternehmen lebenslange Mitgliedschaft bei XYZ ist für Unternehmen, die mehr als 250 Mitarbeiter besitzen."",
      "partPriceNetto" : "500",
      "partPriceBrutto" : "595",
      "partTax" : "19",
      "partUnityID" : "523100"
    },
    {
      "partID" : "45043396",
      "partNumber" : "RT-MG-10000059",
      "partName" : ""Mittlere Unternehmen lebenslange Mitgliedschaft bei XYZ"",
      "partText" : ""Diese Mittlere Unternehmen lebenslange Mitgliedschaft bei XYZ ist für Unternehmen, die bis maximal 249 Mitarbeiter besitzen. \n\nEin späteres Upgrade können Sie bei Bedarf, solange verfügbar, auf eine größere lebenslange Mitgliedschaft mit Anrechnung dieses Preises durchführen oder Sie erhalten einen Rabatt auf die größeren nicht lebenslangen Mitgliedschaften."",
      "partPriceNetto" : "150",
      "partPriceBrutto" : "178",
      "partTax" : "19",
      "partUnityID" : "523100"
    }
  ]
}

As soon as I delete the following line, the output of the Edit Fields node works!

      "partText" : "{{ $json.objects[1].text }}",

Here’s the JSON code again without the deleted line, and it works.

Incorporating JSON.stringify() unfortunately didn’t help at all.

{
  "ltd-parts": [
    {
      "partID" : "{{ $json.objects[0].id }}",
      "partNumber" : "{{$json.objects[0].partNumber }}",
      "partName" : "{{ $json.objects[0].name }}",
      "partText" : "{{ $json.objects[0].text }}",
      "partPriceNetto" : "{{ $json.objects[0].priceNet }}",
      "partPriceBrutto" : "{{ $json.objects[0].priceGross }}",
      "partTax" : "{{ $json.objects[0].taxRate }}",
      "partUnityID" : "{{ $json.objects[0].unity.id }}"
    },
    {
      "partID" : "{{ $json.objects[1].id }}",
      "partNumber" : "{{$json.objects[1].partNumber }}",
      "partName" : "{{ $json.objects[1].name }}",
      "partPriceNetto" : "{{ $json.objects[1].priceNet }}",
      "partPriceBrutto" : "{{ $json.objects[1].priceGross }}",
      "partTax" : "{{ $json.objects[1].taxRate }}",
      "partUnityID" : "{{ $json.objects[1].unity.id }}"
    }
  ]
}

Information on your n8n setup

  • n8n version: 1.95.3
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): ???
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Debian

Do these fields have double quotes for a reason? Check if the input have quotes already and do not add additional quotes at the beginning and the end.

1 Like

No, on a second thought, I think the issue is with "\n"s in the middle of the partText of the second object. Check this out:

your first thought is right!

after removing all double quotes then it will be fine.

don’t need to deal with \n on this.


If you don’t know how to edit the source input double quote. You can easily remove the double quotes in expression.

{
      "partID" : "{{ $json.objects[0].id }}",
      "partNumber" : "{{$json.objects[0].partNumber }}",
      "partName" : {{ $json.objects[0].name }},
      "partText" : {{ $json.objects[0].text }},
      "partPriceNetto" : "{{ $json.objects[0].priceNet }}",
      "partPriceBrutto" : "{{ $json.objects[0].priceGross }}",
      "partTax" : "{{ $json.objects[0].taxRate }}",
      "partUnityID" : "{{ $json.objects[0].unity.id }}"
}

Thank you for your suggestions!
@jabbson and @darrell_tw

The quotation marks obviously multiplied with the copy/paste, as they unfortunately didn’t appear in the output of the edit field.

Now it finally works if I not only remove the quotation marks, but also insert JSON.stringify() into the partText lines. I think I’ve figured it out now.

My conclusion, which I unfortunately haven’t read about in any post here or in the troubleshooting guide on this topic, is this:
If any text formatting, such as the \n character, is expected in a value, you have to use JSON.stringify() and simultaneously omit the “” (quotation marks)! Unfortunately, this doesn’t help on its own.

{
  "ltd-parts": [
    {
      "partID" : "{{ $json.objects[0].id }}",
      "partNumber" : "{{$json.objects[0].partNumber }}",
      "partName" : "{{ $json.objects[0].name }}",
      "partText" : "{{ $json.objects[0].text }}",
      "partPriceNetto" : "{{ $json.objects[0].priceNet }}",
      "partPriceBrutto" : "{{ $json.objects[0].priceGross }}",
      "partTax" : "{{ $json.objects[0].taxRate }}",
      "partUnityID" : "{{ $json.objects[0].unity.id }}"
    },
    {
      "partID" : "{{ $json.objects[1].id }}",
      "partNumber" : "{{$json.objects[1].partNumber }}",
      "partName" : "{{ $json.objects[1].name }}",
      "partText" : {{ JSON.stringify( $json.objects[1].text ) }},
      "partPriceNetto" : "{{ $json.objects[1].priceNet }}",
      "partPriceBrutto" : "{{ $json.objects[1].priceGross }}",
      "partTax" : "{{ $json.objects[1].taxRate }}",
      "partUnityID" : "{{ $json.objects[1].unity.id }}"
    }
  ]
}

Unfortunately, this information was missing here too. Perhaps it can be added or please describe it more clearly if I missed it.

I would imagine that if you don’t just output a value in the {{ }} brackets but execute a function, the “” (quotation marks) would have to be omitted.

1 Like

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