public String objectToJson(Object object) throws IllegalStateException {
  ObjectMapper mapper=new ObjectMapper();
  StringWriter stringWriter=new StringWriter();
  try {
    mapper.writeValue(stringWriter,object);
  }
 catch (  IOException e) {
    throw new IllegalStateException(e);
  }
  return stringWriter.toString();
}

public String objectToJson ( Object object ) throws IllegalStateException { ObjectMapper mapper = new ObjectMapper ( ) ; StringWriter stringWriter = new StringWriter ( ) ; try { mapper . writeValue ( stringWriter , object ) ; } catch ( IOException e ) { throw new IllegalStateException ( e ) ; } return stringWriter . toString ( ) ; }
serializes any java value as json output .
