0

I need to generate a Java class from a JSON response recieved from a web service. I've used JAXB to handle xml, but I don't know how to handle JSON. Does anyone know if a tool exists for this job? Thanks.

p.s.: I need to generate new classes, not convert classes.

1

3 Answers 3

4

Jackson is a good library. Give it a try.

4
  • I personally find Jackson unusable, but I know a number of people that swear by it, and it's probably more ubiquitous than GSON, though it has a lot of specific quirks. Jun 14, 2013 at 14:29
  • I don't have the Java class, I want to generate it from my json, I was reading the Jackson docs and it assumes that I already have the Java class to convert from json. Is it right?
    – Danilo M.
    Jun 14, 2013 at 15:44
  • Jackson will do just about everything but write the class for you. That said, the docs can be a bit confusing. Check out GSON (see my answer) if you're having trouble. Jun 14, 2013 at 15:48
  • Ok, I am going to check again.
    – Danilo M.
    Jun 14, 2013 at 15:53
2

Going to go ahead and say that GSON (http://code.google.com/p/google-gson/) is a lot more user friendly albeit less powerful than Jackson. If you're just getting started with this stuff I'm willing to bet that GSON will give you far less headaches and be closer to what you really want.

1

Check this url: https://github.com/abdulwaheed18/JSON-Tutorial

Hope It will resolve your issue. Particularly check this url :

https://github.com/abdulwaheed18/JSON-Tutorial/blob/master/src/waheed/demo/pojo/json/tutorial/using/jackson/PojoJson.java

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.