I\'ve been trying to create a Jersey REST Webservice. I want to receive and emit JSON objects from Java classes like the following:
@XmlRootElement
public cl
You can use google-gson. Here is a sample code:
@Test
public void testGson(){
Book book = new Book();
book.code = "1234";
book.names = new HashMap();
book.names.put("Manish", "Pandit");
book.names.put("Some","Name");
String json = new Gson().toJson(book);
System.out.println(json);
}
The output is {"code":"1234","names":{"Some":"Name","Manish":"Pandit"}}