通过DWR(直接Web远程处理)获取json [英] Getting json by DWR (Direct Web Remoting)
问题描述
我想知道如何使用DWR将Java对象转换为JSON.我已经尝试过
I want to know how can I convert a Java object to JSON by using DWR. I have already tried
JsonUtil.toJson(myObject)
,但在org.directwebremoting.json.JsonUtil.toJson(JsonUtil.java:127)
处给出NullPointerException
.谁能告诉我将Java对象转换为JSON的任何方法吗?我更希望通过DWR实现.
JsonUtil.toJson(myObject)
, but it gives a NullPointerException
at org.directwebremoting.json.JsonUtil.toJson(JsonUtil.java:127)
. Can anyone tell me any way of converting the Java Object to JSON? I would prefer achieving it by DWR.
推荐答案
为什么不使用JSON库本身? JSON
Why not use the JSON library itself? JSON
甚至Google-Gson库 GSON
Or even the Google-Gson Library GSON
也可以使用搜索"作为进一步参考,因为已经回答了与此类似的问题...
Also, for further reference, use the Search, since similar questions to this one have been answered...
一些例子:
https://stackoverflow.com/questions/338586/a-better-java-json -图书馆
这篇关于通过DWR(直接Web远程处理)获取json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!