Package ubic.gemma.web.controller.util
Class JsonUtil
java.lang.Object
ubic.gemma.web.controller.util.JsonUtil
Utilities for writing JSON payloads to
HttpServletResponse
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
writeErrorToResponse
(int status, String message, javax.servlet.http.HttpServletResponse response) static void
writeErrorToResponse
(Exception e, javax.servlet.http.HttpServletResponse response) Write an error message to the response based on the exception type.static void
writeSuccessToResponse
(javax.servlet.http.HttpServletResponse response) Write a simple JSON object with a "success" key set to true to the response.static void
writeToResponse
(org.json.JSONObject json, javax.servlet.http.HttpServletResponse response)
-
Constructor Details
-
JsonUtil
public JsonUtil()
-
-
Method Details
-
writeSuccessToResponse
public static void writeSuccessToResponse(javax.servlet.http.HttpServletResponse response) throws IOException Write a simple JSON object with a "success" key set to true to the response.- Throws:
IOException
-
writeErrorToResponse
public static void writeErrorToResponse(Exception e, javax.servlet.http.HttpServletResponse response) throws IOException Write an error message to the response based on the exception type.- Throws:
IOException
-
writeErrorToResponse
public static void writeErrorToResponse(int status, String message, javax.servlet.http.HttpServletResponse response) throws IOException - Throws:
IOException
-
writeToResponse
public static void writeToResponse(org.json.JSONObject json, javax.servlet.http.HttpServletResponse response) throws IOException - Throws:
IOException
-