Aleixs Stacks Aleixs Stacks - 4 months ago 38
Node.js Question

NodeJS send array of array

I have a trouble with NodeJS. I have to send an array of array that is structured like this:


So, when I try to do res.send, in my browser (Chrome) I show only

How can I send my array?


The send function expects a JavaScript object, which can be marshalled as a valid JSON string. In your case, you have a JavaScript array, with three properties. But JSON arrays support only integer keys (called indices).

So, you might want to change the array to a JavaScript object, like this

  "val1": ["one", "two", "three"],
  "val2": ["four", "five", "six"],
  "val3": ["seven", "eight", "nine"]