-1
是的,我已经知道如何对象添加到JSON(的NodeJS)
json.newvalue = 'newvalue'
但我不会找那个...... 我有一个空的JSON
plugins = {};
现在我需要5个项目添加到它,例如:
{"name":"test"}
{"name":"test2"}
我寻找的是这样的:plugins.add({"name":"test"})
是的,我已经知道如何对象添加到JSON(的NodeJS)
json.newvalue = 'newvalue'
但我不会找那个...... 我有一个空的JSON
plugins = {};
现在我需要5个项目添加到它,例如:
{"name":"test"}
{"name":"test2"}
我寻找的是这样的:plugins.add({"name":"test"})
首先,json是一个对象的字符串表示形式,你在代码中拥有的是一个对象。但是,看起来你不需要JavaScript对象,而是一个数组。
var plugins = [];
plugins.push({"name":"test"});
plugins.push({"name":"test2"});
插件现在将
[
{"name", "test"},
{"name", "test2"}
]
这工作过,那么我可以JSON.stringify(); – Community