Working with Arrays and Items - Removing "json:" from items

Describe the issue/error/question

I am trying to work with some array data from a node (Notion) that outputs multiple items:

However it doesn’t behave like a normal array (which is preventing me from using some ES6 array functions, that otherwise work perfectly fine in n8n with manually created array structures). Shown below is also array2 which works perfectly fine with the array functions.

When I return the $items array, called array, you can see that json is added, which is not added to the manually created array, array2.

Please share the workflow

Would be grateful for any feedback on what needs to be done to $items to fix this issue!

HI @pb84

When retrieving the $items() you get the full items array which contains json and binary data. If you then put this in a field you will simply get the full items array in that single field.
When creating your own array you also have that JSON key set but n8n will interpret your array and it gets split with the JSON data and binary data to show you both in the GUI.

[
	{
	json:{
		text1:[
			{
			json:{
				id:
			}
			}
		]
		text2:[{
		item1:result1
		item2:result2
		},{
		item1:result1
		item2:result2
		}
		]
	}
	}
]

So they are both set within the json of n8n but your text 1 also includes the full items array with that json you retrieved by getting $items()
The second text is a simple array you build.

Hope this makes sense.
The fix depends on what you actually want to do. using the item lists node will allow you to easily split the items and process from there, if that is what you are after.

2 Likes