public class JSONObject
extends java.util.HashMap<java.lang.String,java.lang.Object>
Constructor and Description |
---|
JSONObject()
Construct an empty JSONObject with a default initial capacity
and load factor.
|
JSONObject(int initialCapacity)
Construct a JSONObject with an initial capacity and default
load factor.
|
JSONObject(int initialCapacity,
float loadFactor)
Constructs a JSONObject with an initial capacity and load
factor.
|
JSONObject(java.util.Map<? extends java.lang.String,? extends java.lang.Object> map)
Construct a JSONObject from an existing map of objects.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
put(java.lang.String key,
java.lang.Object value)
Associates the specified value with the specified key in this
object.
|
void |
putAll(java.util.Map<? extends java.lang.String,? extends java.lang.Object> map)
Copies all of the mappings from the specified map to this map.
|
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
public JSONObject()
public JSONObject(int initialCapacity)
initialCapacity
- initial capacity of the mappublic JSONObject(int initialCapacity, float loadFactor)
public JSONObject(java.util.Map<? extends java.lang.String,? extends java.lang.Object> map)
public java.lang.Object put(java.lang.String key, java.lang.Object value) throws java.lang.ClassCastException
put
in interface java.util.Map<java.lang.String,java.lang.Object>
put
in class java.util.HashMap<java.lang.String,java.lang.Object>
key
- JSON object field name with which the specified
value is to be associatedvalue
- value for the JSON fieldkey
, or
null
if there was no mapping for key
.java.lang.NullPointerException
- if the key
is nulljava.lang.ClassCastException
- if the passed in value is not a
suitable JSON objectpublic void putAll(java.util.Map<? extends java.lang.String,? extends java.lang.Object> map) throws java.lang.ClassCastException
putAll
in interface java.util.Map<java.lang.String,java.lang.Object>
putAll
in class java.util.HashMap<java.lang.String,java.lang.Object>
map
- mappings to be stored in this mapjava.lang.NullPointerException
- if the specified map is null or contains null keysjava.lang.ClassCastException
- if the passed in value is not a
suitable JSON object