Package org.json

Class HTTP


  • @Deprecated
    public class HTTP
    extends java.lang.Object
    Deprecated.
    Use javax.json or other other json libraries instead
    Convert an HTTP header to a JSONObject and back.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CRLF
      Deprecated.
      Carriage return/line feed.
    • Constructor Summary

      Constructors 
      Constructor Description
      HTTP()
      Deprecated.
       
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static JSONObject toJSONObject​(java.lang.String string)
      Deprecated.
      Convert an HTTP header string into a JSONObject.
      static java.lang.String toString​(JSONObject jo)
      Deprecated.
      Convert a JSONObject into an HTTP header.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CRLF

        public static final java.lang.String CRLF
        Deprecated.
        Carriage return/line feed.
        See Also:
        Constant Field Values
    • Constructor Detail

      • HTTP

        public HTTP()
        Deprecated.
    • Method Detail

      • toJSONObject

        public static JSONObject toJSONObject​(java.lang.String string)
                                       throws JSONException
        Deprecated.
        Convert an HTTP header string into a JSONObject. It can be a request header or a response header. A request header will contain
        {
            Method: "POST" (for example),
            "Request-URI": "/" (for example),
            "HTTP-Version": "HTTP/1.1" (for example)
         }
        A response header will contain
        {
            "HTTP-Version": "HTTP/1.1" (for example),
            "Status-Code": "200" (for example),
            "Reason-Phrase": "OK" (for example)
         }
        In addition, the other parameters in the header will be captured, using the HTTP field names as JSON names, so that
            Date: Sun, 26 May 2002 18:06:04 GMT
            Cookie: Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s
            Cache-Control: no-cache
        become
        {...
            Date: "Sun, 26 May 2002 18:06:04 GMT",
            Cookie: "Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s",
            "Cache-Control": "no-cache",
         ...}
        It does no further checking or conversion. It does not parse dates. It does not do '%' transforms on URLs.
        Parameters:
        string - An HTTP header string.
        Returns:
        A JSONObject containing the elements and attributes of the XML string.
        Throws:
        JSONException
      • toString

        public static java.lang.String toString​(JSONObject jo)
                                         throws JSONException
        Deprecated.
        Convert a JSONObject into an HTTP header. A request header must contain
        {
            Method: "POST" (for example),
            "Request-URI": "/" (for example),
            "HTTP-Version": "HTTP/1.1" (for example)
         }
        A response header must contain
        {
            "HTTP-Version": "HTTP/1.1" (for example),
            "Status-Code": "200" (for example),
            "Reason-Phrase": "OK" (for example)
         }
        Any other members of the JSONObject will be output as HTTP fields. The result will end with two CRLF pairs.
        Parameters:
        jo - A JSONObject
        Returns:
        An HTTP header string.
        Throws:
        JSONException - if the object does not contain enough information.