当前位置:编程学习 > JAVA >>

json转换问题


"listhostnetworkcmdresponse" :  
{ "null" : 
{
"listBridge":[
{"bridgename":"management","type":"bridge" },
{"bridgename":"management","type":"bridge" }
 ],

"listBond":
[
{"bondname":"bond0","type":"bond"},
{"bondname":"bond0","type":"bond"}
],
"listPhysical":

{"physicalname":"eth8","type":"physical","speed":"100Mb/s"} ,
{"physicalname":"eth8","type":"physical","speed":"100Mb/s"}
]

}    
}
怎么把上面的json 在js页面 转变成
下面的样子?

   
{
"listall":[
{"bridgename":"management","type":"bridge" },
{"bridgename":"management","type":"bridge" },

{"bondname":"bond0","type":"bond"},
{"bondname":"bond0","type":"bond"},
{"physicalname":"eth8","type":"physical","speed":"100Mb/s"} ,
{"physicalname":"eth8","type":"physical","speed":"100Mb/s"} 
 ] 
}   或这个样子都可以
{
"listall"{
{"bridgename":"management","type":"bridge" },
{"bridgename":"management","type":"bridge" },

{"bondname":"bond0","type":"bond"},
{"bondname":"bond0","type":"bond"},
{"physicalname":"eth8","type":"physical","speed":"100Mb/s"} ,
{"physicalname":"eth8","type":"physical","speed":"100Mb/s"} 
}

其中listBridge,listBond,listPhysical下面的对象个数不是固定的
大家互相讨论哈  请教了 谢谢。。。 
json --------------------编程问答-------------------- 目测JSON里做固定标记为,前台JS遍历去做 --------------------编程问答-------------------- 除 --------------------编程问答-------------------- JsonArray("listBond","{......}");
通过JSonArray也可以得到你想要的效果
--------------------编程问答-------------------- 楼主想想怎么在后台直接做成你想要的不就行了。
补充:Java ,  Web 开发
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,