FreeMarker怎样解析JSON的啊。。。

宇寒 发布于 2013/11/13 09:19
阅读 10K+
收藏 5

@opal 你好,想跟你请教个问题:FreeMarker怎样解析JSON的啊。。。

比如下面这种,或者更复杂的

{"res":"0","msg":"OK","count":"3","pagenum":"1","pagesize":"1","totalpage":"1","userlist":[{"id":"1","name":"aa","sex":"男","age":"22"},{"id":"2","name":"bb","sex":"男","age":"21"},{"id":"3","name":"cc","sex":"女","age":"20"}]}

我的邮箱:xhdyw1225@126.com

加载中
1
opal
opal

<#assign text>

{"res":"0","msg":"OK","count":"3","pagenum":"1","pagesize":"1","totalpage":"1","userlist":[{"id":"1","name":"aa","sex":"男","age":"22"},{"id":"2","name":"bb","sex":"男","age":"21"},{"id":"3","name":"cc","sex":"女","age":"20"}]}

</#assign>

<#assign json=text?eval />

<#list json.userlist as item>

id:${item.id}, name:${item.name},sex:${item.sex}

</#list>

0
宇寒
宇寒

小弟初学这玩意,不是很明白

再请教下"res"那些又是怎么解析的呢。

0
opal
opal

${json.res}

要学会变通啊

0
宇寒
宇寒
。。。非常感谢大神的帮助
0
L
Lijiansheng
大神阿。收藏了
0
zdf123
zdf123

如何处理返回值的json,请各位大神指教

返回顶部
顶部