Json to array comma

Hello everyone.

I trying to convert a json data to a string comma separated.

Json is like this one:

[
  {
    "id": "625d757724acbe52634e6172",
    "idBoard": "625850ac4247c214ff3dc167",
    "name": "ANGELIS",
    "color": "yellow"
  },
  {
    "id": "625d57da6bfa728b6684ed43",
    "idBoard": "625850ac4247c214ff3dc167",
    "name": "JORNALISMO",
    "color": "pink"
  }
]

And I´m looking to transform it to:
ANGELIS, JORNALISMO

Thanks a lot!!

Hey @lux, welcome to the community :tada:

You can use the Item Lists node to first split out the Etiquetas1 field, then another Item Lists node to aggregate the names node.

In case you want a string in the end (instead of an array), I’ve also added a Set node in this example. The expression used here can be auto-generated by n8n when clicking on the little button next to the name field and selecting “Values” from the menu:

This is the result:

image

Hope this helps!

OMG… YOU ARE THE MAN!

That solution is PERFECT.
Thanks a lot

1 Like

Oh… I´m back…

Now I have another problem. That solution worked with only one record…

I have about 140 items and I can´t loop to set the value the way you did.

I tryied with Split in Batches without success.

Can you give me another hand, please??

Happy to take a look. Could you share the JSON data you are currently having? Just to make sure I am not missing something here?

Hello again @MutedJam

The result I´m looking for is

id, name and label name

[
  {
    "id": "6283a9a35222cd69d54a3553",
    "name": "Bob",
    "labels": [
      {
        "id": "625d757724acbe52634e6172",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "Phone",
        "color": "yellow"
      }
    ]
  },
  {
    "id": "627c2f56c2caca8f8c3b3403",
    "name": "John",
    "labels": [
      {
        "id": "625850af0d11210a77426dae",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "PÓS",
        "color": "orange"
      },
      {
        "id": "625d756adc7bb88ab1efd230",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "Whatsapp",
        "color": "green"
      },
      {
        "id": "625d76ed83f7035702e9a789",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "DAVID",
        "color": "lime"
      },
      {
        "id": "6272bc6f13a87970cb96b312",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "BOT",
        "color": "sky"
      }
    ]
  },
  {
    "id": "6260463daa491431ca382392",
    "name": "Mike",
    "labels": [
      {
        "id": "62604608c1d9774e91bf434f",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "Visit",
        "color": "pink"
      },
      {
        "id": "625f1533cfd50d4fdc27b9c4",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "Discount",
        "color": "lime"
      }
    ]
  },
  {
    "id": "627016862b98565ea7cc320e",
    "name": "Mary",
    "labels": [
      {
        "id": "625d756adc7bb88ab1efd230",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "Whatsapp",
        "color": "green"
      },
      {
        "id": "625850b1dd8dd158adcaa625",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "1st class",
        "color": "blue"
      }
    ]
  },
  {
    "id": "6270175070a73265ad674753",
    "name": "Phil",
    "labels": [
      {
        "id": "625d756adc7bb88ab1efd230",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "Whatsapp",
        "color": "green"
      },
      {
        "id": "625d574f5242344ca9dc5a92",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "Online",
        "color": "sky"
      },
      {
        "id": "625850b1dd8dd158adcaa625",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "1st class",
        "color": "blue"
      }
    ]
  },
  {
    "id": "627c2f0c8f09323a3e5b926e",
    "name": "Fer",
    "labels": [
      {
        "id": "625d76ed83f7035702e9a789",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "DAVID",
        "color": "lime"
      },
      {
        "id": "625850af0d11210a77426dae",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "weekend",
        "color": "orange"
      },
      {
        "id": "6272bc6f13a87970cb96b312",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "Comerc",
        "color": "sky"
      },
      {
        "id": "625d756adc7bb88ab1efd230",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "Whatsapp",
        "color": "green"
      }
    ]
  },
  {
    "id": "6272c73677b45586b3cea71c",
    "name": "Bill",
    "labels": [
      {
        "id": "625850af0d11210a77426dae",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "Bot",
        "color": "orange"
      },
      {
        "id": "625d756adc7bb88ab1efd230",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "Whatsapp",
        "color": "green"
      }
    ]
  },
  {
    "id": "62824d6c7b0c45125e4bdca2",
    "name": "Cathy",
    "labels": [
      {
        "id": "625850af5ad9b11b3b279823",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "Whatsapp",
        "color": "red"
      },
      {
        "id": "625d57da6bfa728b6684ed43",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": 2022,
        "color": "pink"
      },
      {
        "id": "625850b0615cb2773f88aa8e",
        "idBoard": "625850ac4247c214ff3dc167",
        "name": "1st class",
        "color": "purple"
      }
    ]
  }
]

Thanks a lot !!

So this looks like a different transformation than the initial one, I suppose you have already applied some logic to it? Either way, I think a single Set node is what you’re looking for here:

The expression used here is just something I clicked together in the expression editor, so you could easily adjust it as needed:

This is the workflow:

Hope this helps!