public static void prettyPrintJSONResponse ( Logger logger , String jsonString ) { if ( logger . isDebugEnabled ( ) ) { // it can fail...on 404 it usually not a json String s ; try { final JsonElement element = new JsonParser ( ) . parse ( jsonString ) ; s = new GsonBuilder ( ) . setPrettyPrinting ( ) . create ( ) . toJson ( element ) ; } catch ( Exception e ) { s = jsonString ; } logger . debug ( "Received JSON response from Instagram - " + s ) ; } }
Pretty print the JSON response in the logs