Class JSONObject<K,V>

All Implemented Interfaces:
JSONAware, Serializable, Cloneable, Map<K,V>

public class JSONObject<K,V> extends LinkedHashMap<K,V> implements Map<K,V>, 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()
    • JSONObject

      public JSONObject(int initialCapacity, float loadFactor)
    • JSONObject

      public JSONObject(int initialCapacity)
    • JSONObject

      public JSONObject(Map<? extends K,? extends V> m)
    • JSONObject

      public JSONObject(int initialCapacity, float loadFactor, boolean accessOrder)
    • JSONObject

      public JSONObject(K key, V value)
  • 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<K,V>
    • toString

      public static String toString(String key, Object value)