Aleixs Stacks Aleixs Stacks - 1 year ago 273
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?

Answer Source

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"]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download