How can we read a JSON object in a JSP, Servlet or in any other Java program?
Asked
Active
Viewed 1.4k times
5
-
can we use gson object for this? – Sadesh Kumar N Nov 25 '09 at 16:13
5 Answers
6
I would recommend using Gson for 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
5
With the json library, there is a JAR of it located here. Also, based upon this answer, you might want to look at JSON-lib

Community
- 1
- 1

John Paulett
- 15,596
- 4
- 45
- 38
3
JSON.org has a lot of good information on reading JSON in Java (and other languages as well). They provide a good reference implementation that many other libraries use.

Kevin
- 30,111
- 9
- 76
- 83
-
That's a good page -- not sure the ref impl is all that great (almost all alternatives from the page are better IMO), but it's good it has been available for years now, and has encourages others to implement better alternatives. :-) – StaxMan Nov 26 '09 at 06:24
2
Using a library such as the one described at: http://www.json.org/java/
Looking at the description of gson, it certainly looks like it would do the job as well.

Andy
- 8,870
- 1
- 31
- 39