private static JSONObject parseRequestJSONObject ( final HttpServletRequest request , final HttpServletResponse response ) { response . setContentType ( "application/json" ) ; try { BufferedReader reader ; try { reader = request . getReader ( ) ; } catch ( final IllegalStateException illegalStateException ) { reader = new BufferedReader ( new InputStreamReader ( request . getInputStream ( ) ) ) ; } String tmp = IOUtils . toString ( reader ) ; if ( StringUtils . isBlank ( tmp ) ) { tmp = "{}" ; } else { if ( StringUtils . startsWithIgnoreCase ( tmp , "%7B%22" /* {" */ ) ) { tmp = URLs . decode ( tmp ) ; } } return new JSONObject ( tmp ) ; } catch ( final Exception e ) { LOGGER . log ( Level . ERROR , "Parses request JSON object failed [" + e . getMessage ( ) + "], returns an empty json object" ) ; return new JSONObject ( ) ; } }
Gets the request json object with the specified request .