I have an array
var user=[];
user['name']="joy";
user['age']= "12";
is there any function in node.js .So that i can get the json output like
{"name":"joy","age":"12"}
I have an array
var user=[];
user['name']="joy";
user['age']= "12";
is there any function in node.js .So that i can get the json output like
{"name":"joy","age":"12"}
No, there is no predefined function in nodejs that will do it for you. But as said by the others, you can do it manually or avoid the problem by defining the array as an objet.
Thank you for your suggestion.And i got the answer that i want.
var user = {};
user.name = "joy";
user.age = "12";
JSON.stringify(user)