Best answer

How to get the 1st array in an array of array ?

  • 1 August 2020
  • 4 replies

Userlevel 1

Hi all,

I encountered that proble that I would like to get the 1st array in an array of array.

[1,2,3], [4,5,6], [7,8,9]

And I only want to pick the 1st set, [1,2,3].

I tried for a long time, but it will turn to 1,2,3,4,5,6,7,8,9 and output 1 only.

Could you help to provide some helps? Thanks


Best answer by andywingrave 5 August 2020, 15:52

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

4 replies

Userlevel 7
Badge +9

Hey! If you want to combine all of this into one array, you can do this with a code-step and a small bit of JavaScript. If you’re just wanting to get each value from item_1, you can do this with the Formatter step, and “Split”, making sure to split on the comma. Something like this, for example:



Userlevel 7
Badge +11

Hi @BabyBossJack!

There’s a similar posts here, where someone was trying to work with nested arrays:

Can you check that out to see if it gets you closer to what you need?

+1, running into the same problem. Response from an app such as Shopify’s Order Fulfillment Variants contains Arrays of IDs sent with each fulfillment. @nicksimard  When attempting to use Line-Item to Text or use this field in other triggers it is converted to comma separated list of all the IDs so unable to extract the first set of IDs

Shopify Fulfillment Line Items Variant IDs Array
Transformed Input
Output of Line-Item to Text

Desired output would be item_1: 33195676041347, item_2: 32587763548291,33918456365187. Or any other way to parse out these separate arrays would be ideal.

Hey @andywingrave, so actually the desired behavior is to extract the items of the first array given the  output of an App is as such [1,2,3], [4,5,6], [7,8,9]. When we pass it into a code step or formatter it is transformed/read in as 1, 2, 3, 4, 5, 6, 7, 8, 9 and thus we lose the ability to segment out the first array values (1, 2, 3)