在 Java 中读取 JSON 对象
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1798038/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
read a JSON object in java
提问by Sadesh Kumar N
How can we read a JSON object in a JSP, Servlet or in any other Java program?
我们如何在 JSP、Servlet 或任何其他 Java 程序中读取 JSON 对象?
回答by BalusC
I would recommend using Gsonfor this. It has the advantage that it supports generics very well and it is also performant. I've posted a Gson#fromJson()example before here: Converting JSON to Java
我建议为此使用Gson。它的优点是它很好地支持泛型并且它也是高性能的。我Gson#fromJson()之前在这里发布过一个例子:Converting JSON to Java
回答by John Paulett
回答by Kevin
回答by Andy
Using a library such as the one described at: http://www.json.org/java/
使用库,例如在:http: //www.json.org/java/ 中描述的库
Looking at the description of gson, it certainly looks like it would do the job as well.
查看gson的描述,它当然看起来也能完成这项工作。

