Getting JSON parse Errors - can't find what's wrong with the JSON

As stated in the Topic name, no idea what’s wrong with the JSON I’m trying to parse:

"{ "Dateiname": "", "Bill Date (ISO)": "2023-10-10", "Bill by (Company Name)": "Relevance AI", "Bill by (Company Email)": "[email protected]", "Reference ID": "3A86F7360003", "File": "", "Company": "", "VAT/UID": "", "Address": "L6, 320 Pitt St, Sydney New South Wales 2000, Australia", "Amount (Decimal)": 19.00, "Sales Tax (Decimal)": 0.00, "Currency (XXX)": "USD", "Bankbewegung": "", "Party": "[email protected]" }"

Error is ERROR: Unexpected token in JSON at position 173 [line 3]

My Code is:

const data = $input.first().json.message.content;

const parsedData = JSON.parse(data);

return { data };

Any ideas?

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:

@Felix_Hausler1 , perhaps the string includes some “control characters”, which are invisible but break transformation to JSON. Try sanitizing the string first. For example,

JSON.parse(data.replace(/[\u0000-\u001F\u007F-\u009F\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g, ""));

There could be other characters not covered by this replace() function but I only could guess here.

Hi there,

It looks like the JSON parsing issue might be related to the structure of the data or a syntax error. To better assist you, could you please share the n8n nodes you are using to handle this JSON parsing? It would help me pinpoint the problem more accurately.

Had to previously delete because of credentials - but it seems that the deleted ones can still be seen - any idea how to remove?