Handle invalid json because of ""

Describe the problem/error/question

Hi Team,

I’ve encountered an issue where the JSON is invalid due to the presence of double quotes ("). Here’s an example:

{
  "eventTemplateId": "1310909",
  "subjectName": "{{contact.PRENOM | default : ""}} ! On n'attend plus que toi ? "
}

The value of subjectName comes from another node, and it can vary. We need to handle each case to ensure the JSON remains valid.

Could you please help with this?

Thanks!

What is the error message (if any)?

JSON parameter need to be an valid JSON

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):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

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:

Hi @Gouravdev, thank you for reaching out and being a part of the community!

Based on the snippet you’ve shared you’re not accessing the contact data with the correct expression syntax.

{
  "eventTemplateId": "1310909",
  "subjectName": "{{$json?.contact ? $json.contact.PRENOM : '' }}! On n'attend plus que toi?"
}

Note the ternary instead of the pipe. You can see some examples of the expression syntax in our test fixtures for Tournament, our in-house templating language.

1 Like

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