Class JsonUtils


  • public class JsonUtils
    extends java.lang.Object
    JSON utility methods.
    Since:
    4.1
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonUtils()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isValidJson​(java.lang.String json)
      Is valid json?.
      void render​(java.lang.Object model, javax.servlet.http.HttpServletResponse response)
      Render model and view.
      void render​(javax.servlet.http.HttpServletResponse response)
      Render model and view.
      void renderException​(java.lang.Exception ex, javax.servlet.http.HttpServletResponse response)
      Render exceptions.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JsonUtils

        public JsonUtils()
    • Method Detail

      • render

        public void render​(java.lang.Object model,
                           javax.servlet.http.HttpServletResponse response)
        Render model and view.
        Parameters:
        model - the model
        response - the response
      • render

        public void render​(javax.servlet.http.HttpServletResponse response)
        Render model and view. Sets the response status to OK.
        Parameters:
        response - the response
      • renderException

        public void renderException​(java.lang.Exception ex,
                                    javax.servlet.http.HttpServletResponse response)
        Render exceptions. Adds error messages and the stack trace to the json model and sets the response status accordingly to note bad requests.
        Parameters:
        ex - the ex
        response - the response
      • isValidJson

        public boolean isValidJson​(java.lang.String json)
        Is valid json?.
        Parameters:
        json - the json
        Returns:
        the boolean