Code node create Dynamic json

Describe the problem/error/question

Dear,

I would like to have json result dynamically without knows name_key and value as format, is it possible?:

{
 "Agent": "A_AGENT", "ID":"ID_001", "Goal":"Goal n°1 Agent A","Words":'"phone number","email","address"'
}


Thank you.

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

[
{
“mykey”: “A_AGENT”
},
{
“mykey”: “A_AGENT”
},

Information on your n8n setup

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

Could you please expand your explanation a little bit? It is not clear what you goal is? Do you want this to be randomly generated? Please explain what you want to do, what you want to happen, and what doesn’t work right now.

on my code, i have :

result.push({
      "json":
        {
        
        mykey : items[index].json.Agent,
		//			"aBrandNewField": "New data for item " + index
        },
      "pairedItem": index
  });

I must be declare theses :

Is it possible to have dynamic object with a loop key/value without set the real_name of column on the code : list_keys contains the list of key. Example, i set “Agent” : items[index].json.Agent → i would like to have : list_keys[index]: items[index].json.[column_number]

result.push({
      "json":
        {
        
        "Agent" : items[index].json.Agent,
         "ID" : items[index].json.ID,
          "Goal":items[index].json.Goal,
          "Words":items[index].json.Words,
         
		//			"aBrandNewField": "New data for item " + index
        },
      "pairedItem": index
  });







Take a look and let me know if this is something you are looking for:

Yes, it’s my request, thank you.