Split out items complex objects

Hello,

I have a strange issue with my flow, and the Split out items and the error ‘The provided field ‘multilang’ is not an array’.

The purpose of those 2 steps bellow → I want to have a unique item from all the objects contained in multilang data that I get from the MongoDB node.

I put below an example of output if you want to try it on your own:

[
  {
    "multilang": {
      "gb": {
        "href": "www.brastop.com",
        "lang": "en",
        "external": false
      },
      "us": {
        "href": "us.brastop.com",
        "lang": "en",
        "external": true
      },
      "fr": {
        "href": "fr.brastop.com",
        "lang": "fr",
        "external": true
      }
    }
  }
]

Because I want to split in batch after and continue my flow for each item 1 by 1 (in my example us.href & us.lang, uk.href & us.lang, fr.href & fr.lang).

I don’t understand how to fix this, could you help me please ?

Thank you in advance for your help

Hey @Growthiste,

The Item Lists node currently only works with arrays so you would need to use a code node to split out the items.

Hello @Jon ,

Ok i’ll try to find a function to do that! Thank you for your answer jon

How are you getting on @Growthiste, did you find a solution yet? If not, you could try something like this:

Here, Object.keys is used to read all keys from your multilang object, then a new object is defined using the key (gb, us, etc.) in a new “language” field. Afterwards, the spread syntax is used to copy all other properties over to our new object.

Resulting in something like this:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.