Handle invalid json

Describe the problem/error/question

I get data form an api, within there are contact data, which look like a json but are invalid and therefore I get an error in the set node:

I´m getting for sax-address, phone, email an error: invalid json.

ERROR: The entry “contact_address” inside ‘Fields to Set’ in item 52 contains invalid JSON

[{country=usa, road=everett st, city=norwood, postcode=02062, house_number=750, state=ma, source=DCB4 - 750 Everett St, Norwood, MA 02062, USA, house=dcb4}]

Invalid JSON!

Error: Parse error on line 1:

[{country=usa, road=everett st, city=norwood, postcode=02062, house_number=750, state=ma, source=DCB4 - 750 Everett St, Norwood, MA 02062, USA, house=dcb4}]

–^

Expecting ‘STRING’, ‘}’, got ‘undefined’

Any idea?

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

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

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:

Will it let you stringify it?

Hey @Kool_Baudrillard,

The JSON you have is invalid, I quickly ran it through jsonlint.com just to confirm. Normally the data would be something like…

[
    {
        "country": "usa",
        "road": "everett st",
        "city": "norwood",
        "postcode": "02062",
        "house_number": "750",
        "state": "ma",
        "source": "DCB4 - 750 Everett St, Norwood, MA 02062, USA",
        "house": "dcb4"
    }
]

I am not sure why the service you are working with is sending invalid json is it a system you have control over that you can fix?

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