1 public String getJsonString(Object o){ 2 ObjectMapper om = new ObjectMapper(); 3 StringWriter sw = new StringWriter(); 4 try{ 5 JsonGenerator jg = new JsonFactory().createJsonGenerator(ws); 6 om.writeValue(jg,o); 7 jg.close(); 8 }catch(){} 9 return ws.toString() ; 10 } 11 12 public void writeJson(Object o) { 13 String json = getJsonString(o); 14 try{ 15 ServletActionContext.getResponse().getWriter().write(json); 16 }catch(){} 17 }