Getting array inside array

Describe the issue/error/question

I’m trying to extract an array from an array so I can use those values in the following nodes

I get this:

[  
  [
  1517411543616561200,
  1355908649537908700,
  1542435042907103200,
  1577555858002681900,
  1577558825946779600,
  1412005886202110000,
  1405217453999800300,
  1462159484088946700,
  1481317578442223600,
  1521925225650307000,
  1577563439253389300
  ]
] 

But I want this:

[  
  1517411543616561200,
  1355908649537908700,
  1542435042907103200,
  1577555858002681900,
  1577558825946779600,
  1412005886202110000,
  1405217453999800300,
  1462159484088946700,
  1481317578442223600,
  1521925225650307000,
  1577563439253389300
] 

What is the error message (if any)?

ERROR: The provided field '[0]' is not an array

Please share the workflow

Share the output returned by the last node

Expected output:

[  
  1517411543616561200,
  1355908649537908700,
  1542435042907103200,
  1577555858002681900,
  1577558825946779600,
  1412005886202110000,
  1405217453999800300,
  1462159484088946700,
  1481317578442223600,
  1521925225650307000,
  1577563439253389300
] 

Information on your n8n setup

  • n8n version: 0.195.5
  • Database you’re using (default: SQLite): SQLite
  • Running n8n with the execution process [own(default), main]: own
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: docker

Hi @AlejandroAkbal, welcome to the community!

n8n doesn’t really support an array of integers. Instead, it would work internally with an array of objects described here.

What you could, however, do is something like this:

Here you’d have a proper list of n8n items with one property each after your first Item Lists node and could then perform additional operations:

Would this work for you?

Unfortunately, as you can see, when using the HTTP node with the output set to anything other than file, the data is corrupted. Look at the integers, they become something else, dont know why!

The real response is this:

[
  1517411543616561152, 1355908649537908740, 1542435042907103232, 1577555858002681858, 1577558825946779648,
  1412005886202109953,
  1405217453999800322, 1462159484088946689, 1481317578442223629, 1521925225650307072, 1577563439253389316
]

But they are transformed to something else:

[  
  [
  1517411543616561200,
  1355908649537908700,
  1542435042907103200,
  1577555858002681900,
  1577558825946779600,
  1412005886202110000,
  1405217453999800300,
  1462159484088946700,
  1481317578442223600,
  1521925225650307000,
  1577563439253389300
  ]
] 

Ah sorry, this will be because the numbers aren’t suitable integers in JS. If storing this file as an array of strings isn’t an option for you, I think you will need a little custom function to deal with them.

This should do the job:

Result:

Huh, so it’s a problem in the JavaScript engine? It is not working correctly with those numbers?

Yes, the largest safe integer in JS would be 9007199254740991 (16 digits, see here).

Values such as 1517411543616561152 have 19 digits, so they should be represented using a different data type. My recent example should deal with this.

Awesome, thanks for letting me know about this weird issue, just wrapped the data as strings to make things easier

Love your support @MutedJam <3

1 Like

You’re most welcome and sorry for the initial confusion. It doesn’t happen very often this limit is exceeded so I didn’t even think about it until you pointed this out :see_no_evil:

1 Like