A
A
Alexey Maksimov2016-01-26 19:26:34
Node.js
Alexey Maksimov, 2016-01-26 19:26:34

Why doesn't JSON.stringify work?

When I try to serialize an array to JSON format with a native function, JSON.stringify(clients_list)I get an empty string like []. What am I doing wrong?
Array:

var clients_list = [];
clients_list['id'] = [];
clients_list['session'] = [];
clients_list['id'][0] = 1;
clients_list['session'][0] = 1;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2016-01-26
@additivex

You wanted to declare an object
, but you declared an array
var clients_list = [ ];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question