• Post Reply Bookmark Topic Watch Topic
  • New Topic

Json Parser

 
Fawad Ali
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I do not know if this is a related forum or not but I am working in web so I guess it will be. I have a situation where I am getting a json String from request in a java class. Now I want to parse the json string to get appropriate values. Can anyone tell me which library should I use for this. An example will be great.
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used this Java implementation of JSON: http://www.json.org/java/index.html. There are others, but JSON is pretty simple so there isn't much to go wrong. As for examples, you've got the API documentation there and you'll see it's pretty simple. It should only take you a few minutes to figure out which objects to use.
 
Nico Van Brandt
Ranch Hand
Posts: 70
IntelliJ IDE Java Mac
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to cast it to a JSONObject and then get the values using the getter methods.
 
Fawad Ali
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys for your help. I am gonna try your solutions.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Google's Gson is another popular library.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!