建立一个数组对象,我有两个目的如下:推JSON
var id="one";
var arrobj = Array[2]
0: Object
name : "a"
desc : "desc1"
1: Object
name : "b"
desc : "desc2"
我想建立对象的格式如下:
var secondobj = [{ "one" : [{ name:"a",desc:"desc1"},{name:"b",desc :"desc2"}] }]
我尝试这样做:
var secondobj= new Array();
var samplejson = {};
我刚刚给了
samplejson.name = id;
在此之后,我有点困惑,因为在如何推动值来获得上述数据结构。
'VAR secondobj =新阵列(); var samplejson = {}; samplejson.one = arrobj;' – Rayon