Start a Scenario with Json

Hi there
I was wondering how I can start a scenario with the following JSON

[
{
	"code": 886079657,
	"code_client": "1377",
	"name": "ACME",
	"tags": [
		{"tag": "suplier"},
		{"tag": "test2"},
		{"tag": "test1"},
		{"tag": "test3"}
	],
"contry": "EUA",
]

And on a second function insert a code like it

const onlyTags = data.map(f => f.tags.map(t => `VALUE: ${t.tag}`))
onlyTags.push(data.code_client.lenght <= 3 ? "VALUE: 'lower number'" : "VALUE: 'Great number'")

Hi @tuliovargas,

In general you can run any function you like using the Function Node and keeping the n8n data structure in mind.

I am just not sure I fully understand the task you are facing. Do you want to replace the original item (or possibly multiple items with the same structure) with a single item only having the onlyTags field? Or do you want to add the onlyTags field to your existing item?

Hi @MutedJam ,
please, have a look in the code below, I hope it can explain what I want to do:

That is not possible with a Set-Node (at least not easily, clean and simple). To do that you would have to use a Function-Node with the following code:

return [{
  json: {
    propertyName: [
      {
        "code": 886079657,
        "code_client": "1377",
        "name": "ACME",
        "tags": [
          {"tag": "suplier"},
          {"tag": "test2"},
          {"tag": "test1"},
          {"tag": "test3"}
        ],
        "contry": "EUA",
      }
    ]
  }
}]
1 Like