public static String stringify ( Object object , String indentString ) throws IOException { if ( object == null ) { return null ; } Writer out = new StringWriter ( ) ; JsonWriter jsonWriter = new JsonWriter ( out , indentString ) ; jsonWriter . write ( object ) ; jsonWriter . close ( ) ; return out . toString ( ) ; }
Converts an object to a JSON formatted string . If pretty - printing is enabled includes spaces tabs and new - lines to make the format more readable .