public static String writePretty ( JsonObject jsonObject ) { JsonWriterFactory factory = createPrettyWriterFactory ( ) ; StringWriter sw = new StringWriter ( ) ; JsonWriter writer = factory . createWriter ( sw ) ; writer . writeObject ( jsonObject ) ; String ret = sw . toString ( ) ; writer . close ( ) ; return ret ; }
write a JsonObject formatted in a pretty way into a String