Creating and setting column in JavaScript object

Describe the problem/error/question

I have a stringified JSON which I am parsing into JSON and attempting to create a new column for the object. I want to extract the date from a previous node and set it here. When I try to set this new columns value though, it doesnt error out or set the new column as I expect.

This is the Javascript code I am using to do the transformation:

// convert stringified JSON to JSON
const stringJSON = $input.all()[0].json.json_data;
const dateStr = $input.all()[0];
const dateObj = new Date(dateStr);
const formattedDate = dateObj.toISOString().split(‘T’)[0];
const jsonObject = JSON.parse(stringJSON); = formattedDate
return jsonObject;

What is the error message (if any)?


Please share your workflow

Share the output returned by the last node

“success”: true

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:

Hi @graham_vai, I am sorry you’re having trouble.

When trying to reproduce this your example Code is, however, working for me as it should.

Seeing I don’t have access to your emails or OpenAI account, I’ve created the below dummy workflow including your Code node to test this:

This was on n8n 1.1.1. Perhaps you can confirm the version of n8n you are currently using and provide an example workflow I can run on my end to see your problem first hand?

Hi, Thanks for the reply! My mistake, I just had to iterate over each item in the json object.

Sorry for that. Thank you again.


No worries at all, glad to hear you figured it out :slight_smile:

1 Like

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