private static byte [ ] transform ( final InputStream body ) throws IOException { final ByteArrayOutputStream res = new ByteArrayOutputStream ( ) ; try ( JsonReader rdr = Json . createReader ( body ) ) { final JsonObject obj = rdr . readObject ( ) ; try ( JsonWriter wrt = Json . createWriterFactory ( Collections . singletonMap ( JsonGenerator . PRETTY_PRINTING , true ) ) . createWriter ( res ) ) { wrt . writeObject ( obj ) ; } } catch ( final JsonException ex ) { throw new IOException ( ex ) ; } return res . toByteArray ( ) ; }
Format body with proper indents .