当前位置: 代码迷 >> Java Web开发 >> jsp页面解析json数组, 多谢
  详细解决方案

jsp页面解析json数组, 多谢

热度:280   发布时间:2016-04-16 21:47:28.0
jsp页面解析json数组,在线等 谢谢
如题:
json数组如下
[{"Status Code":"200","Server":"Apache-Coyote/1.1","Content-Type":"application/json","Transfer-Encoding":"chunked","Date":"Wed, 22 Oct 2014 09:23:38 GMT"},{"apikey":"0D5F8AF7-AC5E-299B-58E9DFCC8CF6","command":"123","params":"none","effect":""}]

想把json数组中第一个对象平成一个表格
想要的效果如下
<tr>
<td>Status Code</td>
<td>200</td>
</tr>
<tr>
<td>Server</td>
<td>Apache-Coyote/1.1</td>
</tr>


------解决思路----------------------
用jquery解析这个json就行
------解决思路----------------------
引用:
如题:
json数组如下
[{"Status Code":"200","Server":"Apache-Coyote/1.1","Content-Type":"application/json","Transfer-Encoding":"chunked","Date":"Wed, 22 Oct 2014 09:23:38 GMT"},{"apikey":"0D5F8AF7-AC5E-299B-58E9DFCC8CF6","command":"123","params":"none","effect":""}]

想把json数组中第一个对象平成一个表格
想要的效果如下
<tr>
<td>Status Code</td>
<td>200</td>
</tr>
<tr>
<td>Server</td>
<td>Apache-Coyote/1.1</td>
</tr>


这是要把列转变成行么?
------解决思路----------------------
jQuery ajax  请求返回JSON  然后append拼成想要得HTML
------解决思路----------------------
var data= [{"Status Code":"200","Server":"Apache-Coyote/1.1","Content-Type":"application/json","Transfer-Encoding":"chunked","Date":"Wed, 22 Oct 2014 09:23:38 GMT"},{"apikey":"0D5F8AF7-AC5E-299B-58E9DFCC8CF6","command":"123","params":"none","effect":""}]
var htmlStr = "";
for(var key in data[0]){
var html = '<tr><td>'+key+'</td><td>'+data[0][key]+'</td></tr>';
htmlStr+=html;
}
$(htmlStr).appendTo();
遍历json第一个节点的所有属性解析成html
  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!
 
  • 最近登录:Sat Nov 25 07:47:42 CST 2017
  • 最近登录:Sat Nov 25 07:47:42 CST 2017
  • 最近登录:Sat Nov 25 07:47:42 CST 2017
  • 最近登录:Sat Nov 25 07:47:42 CST 2017
  • 最近登录:Sat Nov 25 07:47:42 CST 2017