我想问一个关于将数组转换为jsonArray的问题。这是我获取jsonArray的代码
[
{id=10,job:computer, place:near}
{id=11,job:computer2, place:near2}
[
{id=14,job:computer, place:near3}
{id=11,job:computer2, place:near2}
{id=10,job:computer2, place:near2}
],
{id3=101,jobr:computerr, placer:nearr}
[
{id3=14,jobr:computerr, placre:nearrrr}
],
]
我需要这种格式的json。但是
var arr =
[
{
id:'grid1',
all:
[
{id=14,job:computer, place:near3},
{id=11,job:computer2, place:near2},
{id=10,job:computer2, place:near2}
],
change:
[
{id=10,job:computer, place:near}
{id=11,job:computer2, place:near2}
]
},
{
id:'grid2',
all:
[
{id3=14,jobr:computerr, placre:nearrrr}
],
change:
[
{id3=101,jobr:computerr, placer:nearr}
]
}
]
我的代码使用
obj = {};
$.each(cols[0].Values,function(key,value){
obj[value.Value] = value.Display;
});
答案 0 :(得分:0)
以下是我解决这个问题的方法:
var coords=[]
coords.push({ 'Id': $(myGrid)[0].id, 'ChangeRecord': coords2, 'all': gridData });