js中如何把json数组转成json对象
JSONArray jsonarray = JSONArray.fromObject(comList);
//List<String> strList = new ArrayList<String>();
pWriter.print(jsonarray);
ajax到后台获得的json数组
var json =
[
{
"cId":"0011",
"cName":"aaa",
"list":[
{"dId":"0001","dName":"监查审计部","deptList":[]},
{"dId":"Dpt0002","dName":"财务部","deptList":[]
]
},
{
"cId":"0001",
"cName":"bbb",
"list":[
]
}
]
想把他转成json对象,一定要是json对象
var newJson = {
id:"0011",
name:"aaa",
children:[
{
id:"0001",
name:"监查审计部",
children:[]
},
{
id:"Dpt0002",
name:"财务部",
children:[]
}
]
},
{
id:"0001",
name:"bbb",
children:[]
}
就是json数组 转换成json对象,必须是
[解决办法]
可以,把这个数组赋值为一个json对象的value
[解决办法]
eval ...