Class JSONResponse

  • public class JSONResponse
    extends Object
    Static helper methods to build up JSON-like Response objects and error handling.
    Joerg Plewe - Initial contribution, Henning Treu - Provide streaming capabilities
    • Method Detail

      • createErrorResponse

        public static createErrorResponse​( status,
                                                                    String errormessage)
        in case of error (404 and such)
        status -
        errormessage -
        Response containing a status and the errormessage in JSON format
      • createResponse

        public static createResponse​( status,
                                                               Object entity,
                                                               String errormessage)
        Depending on the status, create a Response object containing either the entity alone or an error JSON which might hold the entity as well.
        status - the status for the response.
        entity - the entity which is transformed into a JSON stream.
        errormessage - an optional error message (may be null), ignored if the status family is successful
        Response configure for error or success