Class JSONObject

All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>, JSONAware

public class JSONObject extends LinkedHashMap<Object,Object> implements Map<Object,Object>, JSONAware
A JSON object. Key value pairs are in the order of adding. JSONObject supports java.util.Map interface.
Author:
FangYidong<fangyidong@yahoo.com.cn>
See Also:
  • Constructor Details

    • JSONObject

      public JSONObject()
  • Method Details

    • toJSONString

      public static String toJSONString(Map map)
      Convert (aka., encode) a map to JSON text. The result is a JSON object. If this map is also a JSONAware, JSONAware specific behaviors will be omitted at this top level.
      Parameters:
      map -
      Returns:
      JSON text, or "null" if map is null.
      See Also:
    • toJSONString

      public String toJSONString()
      Encodes this object to a JSON string. It is the same as toString().
      Specified by:
      toJSONString in interface JSONAware
      Returns:
      JSON text
    • toString

      public String toString()
      Encodes this object to a JSON string. It is the same as toJSONString().
      Overrides:
      toString in class AbstractMap<Object,Object>
    • toString

      public static String toString(String key, Object value)