Question about node

Hi, I’m stuck on a node again. In the edit fields node, I put this JSON code to give it 2 items as input to test how the “loop” node worked. However, it’s giving me an error and I don’t know why.
[
{
“name”: “First item”,
“code”: 1
},
{
“name”: “Second item”,
“code”: 2
}
]

What is the error message (if any)?

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

error

Hey @Pablo_Serrano, while you wait for a response, here are some things that might help:

Suggested resources

Automatically matched to your question.

Docs:

Forum:

@moosa, @hubschrauber, @withabdul - you’ve helped with similar issues before, can you take a look?

Automatically suggested by n8n’s community bot. It’s a pilot - please share feedback here.

Hi @Pablo_Serrano

The Edit Fields node in JSON mode expects a single object, not an array, which is why that errors. It also outputs one item per input item, so it can’t turn one incoming item into two no matter what you paste in.

For test data with multiple items, use a Code node instead:

return [
  { json: { name: 'First item', code: 1 } },
  { json: { name: 'Second item', code: 2 } },
];

That gives the Loop node two real items to iterate over.

If you’d rather not use code, keep the array as a single field in Edit Fields and add a Split Out node after it pointing at that field. Same result, two items.

Muchas gracias!, pero no entiendo entonces por qué a Nick Saraev con el input que intenté al principio le funciona

@Pablo_Serrano

Look at the purple bar above the OUTPUT panel in your screenshot: “This data is pinned”. I think so that Nick isn’t putting that JSON into the node at all, the mode is Manual Mapping and Fields to Set is empty, so the node isn’t producing anything.

He clicked the pencil icon on the OUTPUT panel and pasted the array there as pinned test data. You can do the same: open the node, click the pencil, paste, save.

Only works for manual runs from the editor though, pinned data is ignored in production.

@Pablo_Serrano

It’s a feature called data pinning. You edit the output panel directly and n8n keeps that data for testing:

So you’re saying that by doing that I could execute the code through edit fields without any problem?

Not quite. Pinning doesn’t execute anything. The node still does nothing, n8n just hands that data to the next node so you can test without a real data source.

That’s fine for playing with the Loop node in the editor, which is all the video is doing. But once you activate the workflow the pin is ignored and Edit Fields outputs nothing.

So: to test, pin it. To actually generate those two items in a real workflow, use the Code node from my first reply.

I checked the video. He opens the Set node and edits the output directly from the icon in the top right, then saves. n8n pins it from there. Same point though, the data is pinned rather than produced by the node.

[quote=“Pablo_Serrano, post:1, topic:306701”]
[
{

@Pablo_Serrano

Looks like your message got cut off. Can you post it again?

It was a mistake, I just wanted to thank you

Replace the “Edit Fields” node with a “Code” node, as Edit Fields only modifies existing items rather than generating multiple new items from a raw array.

Paste this into the Code node to correctly pass two items to your loop: return [{ json: { name: "First item", code: 1 } }, { json: { name: "Second item", code: 2 } }];

and then later could you edit what was produced with the Code node using Edit fields?