JSON in Java the Right Way -- Action, Jackson!
hello
I hava a json string for the following format
{"Facets":[{"category":"Person","count":17,"Person":[{"count":1,"entity":"Al Faw"},{"count":1,"entity":"Col. Barry Johnson"},{"count":1,"entity}]}
i want to convert back it to a hash map.Is there any way to convert json back to java object
Thanks in advance
Comment by Tatu Saloranta on December 6, 2011 at 10:29pm Yes, you can bind JSON to a POJO or HashMap, both using ObjectMapper.readValue() method, like:
ObjectMapper mapper = new ObjectMapper();
Map<String,Object> map = mapper.readValue(jsonInput, Map.class);
MyBean bean = mapper.readValue(jsonInput, MyBean.class); // assuming it has proper public fields or setters
Comment
© 2013 Created by Tatu Saloranta.
Powered by
You need to be a member of Jackson JSON User Group to add comments!
Join Jackson JSON User Group