tags:

views:

442

answers:

5

how can we read a JSON object in a JSP , Servlet or in any other java program?

+4  A: 

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

John Paulett
+1  A: 

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
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
+1  A: 

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
+2  A: 

Take a look at Jackson.

Jim Ferrans
+2  A: 

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: http://stackoverflow.com/questions/1688099/converting-json-to-java/1688182#1688182

BalusC