public String writeValueAsString ( Object obj , boolean indent ) { try { if ( indent ) { return this . mapper . writer ( ) . withDefaultPrettyPrinter ( ) . writeValueAsString ( obj ) ; } return this . mapper . writeValueAsString ( obj ) ; } catch ( Exception e ) { LogFactory . getLog ( JsonHandler . class ) . info ( "serialize object to json" , e ) ; return null ; } }
Converts an object into a JSON string . In case of an exceptions returns null and logs the exception .