Class JsonHttp

java.lang.Object
google.registry.security.JsonHttp

public final class JsonHttp extends Object
Helper class for servlets that read or write JSON.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    String prefixed to all JSON-like responses.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Map<String,?>
    read(jakarta.servlet.http.HttpServletRequest req)
    Extracts a JSON object from a servlet request.
    static void
    write(jakarta.servlet.http.HttpServletResponse rsp, Map<String,?> jsonObject)
    Writes a JSON servlet response securely with a parser breaker.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • JSON_SAFETY_PREFIX

      public static final String JSON_SAFETY_PREFIX
      String prefixed to all JSON-like responses.
      See Also:
  • Constructor Details

    • JsonHttp

      public JsonHttp()
  • Method Details

    • read

      @Nullable public static Map<String,?> read(jakarta.servlet.http.HttpServletRequest req) throws IOException
      Extracts a JSON object from a servlet request.
      Returns:
      JSON object or null on error, in which case servlet should return.
      Throws:
      IOException - if we failed to read from req.
    • write

      public static void write(jakarta.servlet.http.HttpServletResponse rsp, Map<String,?> jsonObject) throws IOException
      Writes a JSON servlet response securely with a parser breaker.
      Throws:
      IOException - if we failed to write to rsp.