Hacker News new | past | comments | ask | show | jobs | submit login

How do you even parse JSON in Java? I remember in the days of XML, there was a kind of specification standard for the xml (a specification for how to specify a specification?). From that you could generate Java classes that would correspond to the elements of the XML. But for JSON there is no such meta description, so you are stuck with manually parsing the JSON and hoping you catch all nuances?



Have a look at the Jackson library. There are many others.


Typically you create your class manually and map to-and-from json-strings. In a web-context you'd usually let the container handle the serialization/de-serialization (jax-rs), in other contexts I tend to use Google's GSON-library.


There's plenty of libraries for this. Jackson being the best one I've used.


I'd recommend Google Gson; it works either with model classes, or with a generic JsonObject.

Jackson is good, and more powerful in terms of model mapping, but I find it much more complicated to work with.


Google's GSON is the one I've turned to on several projects.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: