src/main/java/com/jmsoftware/datastructuresandalgorithms/common/util/ResponseUtil.java
/**
     * Write data JSON to response.
     *
     * @param response   Response
     * @param httpStatus HTTP status
     * @param data       Data
     */
Write data JSON to response.
@param response   Response
@param httpStatus HTTP status
@param data       Data
Write data JSON to response . @param response Response @param httpStatus HTTP status @param data Data
public static void renderJson(final HttpServletResponse response, final HttpStatus httpStatus, final Object data) {
        standardizeHttpServletResponse(response, httpStatus);
        val responseBodyBean = ResponseBodyBean.ofStatus(httpStatus.getCode(),
                                                         httpStatus.getMessage(), data);
        try {
            response.getWriter().write(MAPPER.writeValueAsString(responseBodyBean));
        } catch (IOException e) {
            log.error("Error occurred when responding a data JSON.", e);
        }
    }
public static void renderJson ( final HttpServletResponse response , final HttpStatus httpStatus , final Object data ) { standardizeHttpServletResponse ( response , httpStatus ) ; val responseBodyBean = ResponseBodyBean . ofStatus ( httpStatus . getCode ( ) , httpStatus . getMessage ( ) , data ) ; try { response . getWriter ( ) . write ( MAPPER . writeValueAsString ( responseBodyBean ) ) ; } catch ( IOException e ) { log . error ( "Error occurred when responding a data JSON." , e ) ; } }
Write data JSON to response.
Write data JSON to response .