Break multiple values in JSON

Hi there, please can you help me?

I have the following output from a node:

and I only need to keep the “Destino dos Dados”.

I’m using a Function Node to split the string using delimiter, but it is handling only the first item.

I’m splitting each “Destino dos Dados” using the delimiter, and also returning them as “asset”, as shown here:

let arr = => item.json['Destino dos Dados']);
let arr2 = arr[0].split('|');
let obj = arr2.reduce((result, item, index, array) => {
        result[index] = {'asset': item}; //a, b, c
        return result
}, {})
return [{
json: Object.values(obj)

I would like to have an output that lists every item in “Destino dos Dados” as “asset” and individually, for all the items in JSON, returning a fresh JSON with “asset” items like shown above. I’m just missing a loop or forEach I guess.

Any tricks on the Funcion, please? :slight_smile:

Thank you!

This might help:

const newItems = [];
items.forEach(i => {
  i.json["Destino dos Dados"].split("|").forEach(x => newItems.push({ json: { asset: x.trim() } }));

return newItems;

Worked perfectly!! Thanks a lot

How would one do the same if would be other way around, like:

“place0”: “Destino dos Dados”,
“place1”: “folder”,
“place3”: “folder”,
“place4”: “folder”
“place0”: “folder”,
“place1”: “folder”,
“place2”: “folder”,
“place3”: “folder”,
“place4”: “Destino dos Dados”
“place5”: “folder”,

Thank you very much.

To filter entries by value:

const target = ['Destino dos Dados']

return => {
	const o = { json: {} };
	Object.keys(i.json).map(k => {
		if (i.json[k].includes(target)) o.json[k] = i.json[k];
	return o;
1 Like