Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSON At in servlet

 
Sonu Sen
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am generating a JSON String at client side that is in JSP page and send to the server means to servlet. And I catch that string in the servlet using getParameter(). But I cant access the single element from that JSON string in the servlet.Please tell me How can servlet reterive the single element from the String.

Eg. {"Iem1":"3","Item2":"4","Item3":"12"}

then I want only 3. How can I get that 3.
 
Guogang Fan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can parse the String yourself with those String functions defined in java.lang.String.
or you can use some Java library to do it
www.json.orghave introduced many java api to handle json .
 
Guogang Fan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can also parse the Json String at client side then send the server what you need.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64826
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you creating a JSON string at all if that's not what you need?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic