我想将 JSON 数据推送到多维数组中。
我有像下面这样的 JSON 数据并且已经解析了它。但我无法将数据添加到数组中。下面的 JSON 仅适用于一页。当我翻第二页时,我也得到 JSON 并检查它是否存在于数组中。如果没有,我想将数据添加到数组中。
JSON数据:
[{
"8":
{"hsid":8,"hstype":1,"width":472,"height":141,"xpos":71,"ypos":28,"title":"For example","angle":0,"shape":0,"hotspotbordercolor":null,"hotspotransparency":null,"gotopage":0},
"10":
{"hsid":10,"hstype":2,"width":120,"height":114,"xpos":422,"ypos":224,"title":"Link","angle":0,"shape":0,"hotspotbordercolor":null,"hotspotransparency":null,"gotopage":0},
"11":
{"hsid":11,"hstype":4,"width":105,"height":77,"xpos":434,"ypos":628,"title":"Go to Page-5","angle":0,"shape":0,"hotspotbordercolor":null,"hotspotransparency":null,"gotopage":5}
}]
我想要这种格式的数组:
myArray = {
1: //page no
{
8: //id
{
"hsid": 8,
"hstype": 1,
"width": 472,
"height": 141
},
10: //id
{
"hsid": 10,
"hstype": 2,
"width": 120,
"height": 114
}
},
2: //page no
{
11: //id
{
"hsid": 11,
"hstype": 4,
"width": 105,
"height": 77
},
15: //id
{
"hsid": 15,
"hstype": 1,
"width": 213,
"height": 207
}
}
};