public class JsonRequestHelper extends Object
Constructor and Description |
---|
JsonRequestHelper() |
Modifier and Type | Method and Description |
---|---|
static org.codehaus.jackson.node.ObjectNode |
createJsonErrorResponse(String message)
Create a JSON error response object
|
static org.codehaus.jackson.node.ObjectNode |
createJsonSuccessResponse(String message,
org.codehaus.jackson.node.ObjectNode result)
Create a JSON success response object
|
static boolean |
isJsonResponseRequested(javax.servlet.http.HttpServletRequest request)
Test whether a JSON response should be returned by inspecting the Accept header.
|
static void |
writeJsonErrorResponse(javax.servlet.http.HttpServletResponse response,
String errorMessage)
Write a JSON error to the response.
|
static void |
writeJsonErrorResponseQuietly(javax.servlet.http.HttpServletResponse response,
String errorMessage)
Write a JSON error to the response without throwing exceptions in case of errors.
|
static void |
writeJsonResponse(javax.servlet.http.HttpServletResponse response,
org.codehaus.jackson.node.ObjectNode json)
Write a JSON object to the response.
|
public static org.codehaus.jackson.node.ObjectNode createJsonErrorResponse(String message)
message
- a message to add to the response, can be nullpublic static org.codehaus.jackson.node.ObjectNode createJsonSuccessResponse(String message, org.codehaus.jackson.node.ObjectNode result)
message
- a message to add to the response, can be nullresult
- a result object to add to the response, can be nullpublic static boolean isJsonResponseRequested(javax.servlet.http.HttpServletRequest request)
request
- the requestpublic static void writeJsonResponse(javax.servlet.http.HttpServletResponse response, org.codehaus.jackson.node.ObjectNode json) throws IOException
response
- the responsejson
- the JSON object to writeIOException
- in case of an exception while serializing the json objectpublic static void writeJsonErrorResponse(javax.servlet.http.HttpServletResponse response, String errorMessage) throws IOException
response
- the responseerrorMessage
- the message to sendIOException
- in case of an exception while serializing the json objectpublic static void writeJsonErrorResponseQuietly(javax.servlet.http.HttpServletResponse response, String errorMessage)
response
- the responseerrorMessage
- the message to sendCopyright © 2019 Communote team. All rights reserved.