JSON output from python CODE node does not include null fields

Describe the problem/error/question

I am using a CODE (python) to transform data produced upstream in my workflow into a somewhat complex JSON format. The JSON schema has a bunch of required fields that must be set to null because my workflow is not supposed to produce that data.
PROBLEM: as I create a python dict that complies with the expected JSON schema I diligently set to None all the fields that must have a null value.
However, when I send it out of the CODE node as output this way:
return [ final_json_dict ]
I see that the node output does not include any of the null fields

What is the error message (if any)?

No error message

Information on your n8n setup

  • **n8n version: 1.77.3 **
  • **Database None **
  • **n8n EXECUTIONS_PROCESS setting: v1 **
  • Running n8n via Cloud
  • Operating system: Mac

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:

Seems so. use the javascript in that case, or populate the nullish fields with the Edit Fields node

@barn4k Thanks for the advice.
I would like to avoid maintaining and expanding javascript code since I am not really proficient with it.
Do you have an example of what you mean with:

populate the bullish fields with the Edit Fields node

1 Like

like this