【发布时间】:2015-07-15 00:44:00
【问题描述】:
我有一个数组
var user=[];
user['name']="joy";
user['age']= "12";
node.js 中是否有任何函数。这样我就可以得到像这样的 json 输出
{"name":"joy","age":"12"}
【问题讨论】:
-
如果你想要对象,只需使用对象文字而不是数组。
fruits = {}; -
如果
var fruits = {};或者生成的json 是[{"name":"joy"},{"age":"12"}]是否可以接受? -
@Vishwanath,它是一个动态创建的数组
-
@MattJones.Instead of looping.is there any defined function for that?
标签: node.js