Package com.alibaba.fastjson2
Class JSONObject
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<String,Object>
-
- com.alibaba.fastjson2.JSONObject
-
- All Implemented Interfaces:
Serializable,Cloneable,InvocationHandler,Map<String,Object>
public class JSONObject extends LinkedHashMap<String,Object> implements InvocationHandler
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description JSONObject()defaultJSONObject(int initialCapacity)JSONObject(int initialCapacity, float loadFactor)JSONObject(int initialCapacity, float loadFactor, boolean accessOrder)JSONObject(Map map)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description JSONObjectclone()booleancontainsKey(Object key)Returns true if this map contains a mapping for the specified keybooleancontainsKey(String key)Returns true if this map contains a mapping for the specified keyvoidcopyTo(Object object, JSONReader.Feature... features)Objecteval(JSONPath path)JSONObjectfluentPut(String key, Object value)Chained addition of elementsvoidforEchArrayObject(String key, Consumer<JSONObject> action)static JSONObjectfrom(Object obj)SeeJSON.toJSON(java.lang.Object)for detailsstatic JSONObjectfrom(Object obj, JSONWriter.Feature... writeFeatures)SeeJSON.toJSON(java.lang.Object)for detailsObjectget(Object key)Returns the Object of the associated keys in thisJSONObject.Objectget(String key)Returns the Object of the associated keys in thisJSONObject.BigDecimalgetBigDecimal(String key)Returns theBigDecimalof the associated keys in thisJSONObject.BigIntegergetBigInteger(String key)Returns theBigIntegerof the associated keys in thisJSONObject.BooleangetBoolean(String key)Returns theBooleanof the associated keys in thisJSONObject.booleangetBooleanValue(String key)Returns a boolean value of the associated key in this object.booleangetBooleanValue(String key, boolean defaultValue)Returns a boolean value of the associated key in this object.ObjectgetByPath(String jsonPath)BytegetByte(String key)Returns theByteof the associated keys in thisJSONObject.byte[]getBytes(String key)bytegetByteValue(String key)Returns a byte value of the associated keys in thisJSONObject.DategetDate(String key)Returns theDateof the associated keys in thisJSONObject.DategetDate(String key, Date defaultValue)DoublegetDouble(String key)Returns theDoubleof the associated keys in thisJSONObject.doublegetDoubleValue(String key)Returns a double value of the associated keys in thisJSONObject.FloatgetFloat(String key)Returns theFloatof the associated keys in thisJSONObject.floatgetFloatValue(String key)Returns a float value of the associated keys in thisJSONObject.InstantgetInstant(String key)Returns theBigIntegerof the associated keys in thisJSONObject.IntegergetInteger(String key)Returns theIntegerof the associated keys in thisJSONObject.intgetIntValue(String key)Returns an int value of the associated keys in thisJSONObject.intgetIntValue(String key, int defaultValue)Returns an int value of the associated keys in thisJSONObject.JSONArraygetJSONArray(String key)Returns theJSONArrayof the associated keys in thisJSONObject.JSONObjectgetJSONObject(String key)Returns theJSONObjectof the associated keys in thisJSONObject.<T> List<T>getList(String key, Class<T> itemClass, JSONReader.Feature... features)LonggetLong(String key)Returns theLongof the associated keys in thisJSONObject.longgetLongValue(String key)Returns a long value of the associated keys in thisJSONObject.longgetLongValue(String key, long defaultValue)Returns a long value of the associated keys in thisJSONObject.<T> TgetObject(String key, TypeReference<T> typeReference, JSONReader.Feature... features)Returns the result of theTypeconverter conversion of the associated value in thisJSONObject.<T> TgetObject(String key, Class<T> type, JSONReader.Feature... features)Returns the result of theTypeconverter conversion of the associated value in thisJSONObject.<T> TgetObject(String key, Type type, JSONReader.Feature... features)Returns the result of theTypeconverter conversion of the associated value in thisJSONObject.<T> TgetObject(String key, Function<JSONObject,T> creator)ObjectgetOrDefault(Object key, Object defaultValue)ObjectgetOrDefault(String key, Object defaultValue)ShortgetShort(String key)Returns theShortof the associated keys in thisJSONObject.shortgetShortValue(String key)Returns a short value of the associated keys in thisJSONObject.intgetSize(String key)if value instance of Map or Collection, return size, other return 0StringgetString(String key)Returns theStringof the associated keys in thisJSONObject.Objectinvoke(Object proxy, Method method, Object[] args)booleanisValid(JSONSchema schema)voidnameFilter(NameFilter nameFilter)static JSONObjectof()JSONObject jsonObject = JSONObject.of();static JSONObjectof(String key, Object value)Pack a pair of key-values asJSONObjectstatic JSONObjectof(String k1, Object v1, String k2, Object v2)Pack two key-value pairs asJSONObjectstatic JSONObjectof(String k1, Object v1, String k2, Object v2, String k3, Object v3)Pack three key-value pairs asJSONObjectstatic JSONObjectof(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4)Pack three key-value pairs asJSONObjectstatic JSONObjectof(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5)Pack three key-value pairs asJSONObjectstatic JSONObjectparse(String text, JSONReader.Feature... features)SeeJSON.parse(java.lang.String)for detailsstatic JSONObjectparseObject(String text)SeeJSON.parseObject(java.lang.String)for detailsstatic <T> TparseObject(String text, TypeReference<T> typeReference, JSONReader.Feature... features)SeeJSON.parseObject(java.lang.String)for detailsstatic <T> TparseObject(String text, Class<T> objectClass)SeeJSON.parseObject(java.lang.String)for detailsstatic <T> TparseObject(String text, Class<T> objectClass, JSONReader.Feature... features)SeeJSON.parseObject(java.lang.String)for detailsstatic <T> TparseObject(String text, Type objectType, JSONReader.Feature... features)SeeJSON.parseObject(java.lang.String)for detailsJSONArrayputArray(String name)JSONObjectputObject(String name)<T> Tto(TypeReference<T> typeReference, JSONReader.Feature... features)Convert thisJSONObjectto the specified Object<T> Tto(Class<T> clazz, JSONReader.Feature... features)Convert thisJSONObjectto the specified Object<T> Tto(Type type, JSONReader.Feature... features)Convert thisJSONObjectto the specified Object<T> Tto(Function<JSONObject,T> function)<T> TtoJavaObject(TypeReference<T> typeReference, JSONReader.Feature... features)Deprecated.since 2.0.4, please useto(Type, JSONReader.Feature...)<T> TtoJavaObject(Class<T> clazz, JSONReader.Feature... features)Convert thisJSONObjectto the specified Object<T> TtoJavaObject(Type type, JSONReader.Feature... features)Deprecated.since 2.0.4, please useto(Type, JSONReader.Feature...)byte[]toJSONBBytes(JSONWriter.Feature... features)Serialize to JSONB bytesStringtoJSONString(JSONWriter.Feature... features)Serialize to JSONStringstatic StringtoJSONString(Object object, JSONWriter.Feature... features)Serialize Java Object to JSONStringwith specifiedJSONReader.Features enabledStringtoString()Serialize to JSONStringStringtoString(JSONWriter.Feature... features)Serialize to JSONStringvoidvalueFilter(ValueFilter valueFilter)-
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, keySet, removeEldestEntry, replaceAll, values
-
Methods inherited from class java.util.HashMap
compute, computeIfAbsent, computeIfPresent, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
Methods inherited from class java.util.AbstractMap
equals, hashCode
-
-
-
-
Constructor Detail
-
JSONObject
public JSONObject()
default
-
JSONObject
public JSONObject(int initialCapacity)
- Parameters:
initialCapacity- the initial capacity = (number of elements to store / load factor) + 1- Throws:
IllegalArgumentException- If the initial capacity is negative
-
JSONObject
public JSONObject(int initialCapacity, float loadFactor)- Parameters:
initialCapacity- the initial capacity = (number of elements to store / load factor) + 1loadFactor- the load factor- Throws:
IllegalArgumentException- If the initial capacity is negative or the load factor is negative- Since:
- 2.0.2
-
JSONObject
public JSONObject(int initialCapacity, float loadFactor, boolean accessOrder)- Parameters:
initialCapacity- the initial capacity = (number of elements to store / load factor) + 1loadFactor- the load factoraccessOrder- the ordering mode - true for access-order, false for insertion-order- Throws:
IllegalArgumentException- If the initial capacity is negative or the load factor is negative- Since:
- 2.0.2
-
JSONObject
public JSONObject(Map map)
- Parameters:
map- the map whose mappings are to be placed in this map- Throws:
NullPointerException- If the specified map is null
-
-
Method Detail
-
get
public Object get(String key)
Returns the Object of the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned
-
get
public Object get(Object key)
Returns the Object of the associated keys in thisJSONObject.
-
containsKey
public boolean containsKey(String key)
Returns true if this map contains a mapping for the specified key- Parameters:
key- the key whose presence in this map is to be tested
-
containsKey
public boolean containsKey(Object key)
Returns true if this map contains a mapping for the specified key- Specified by:
containsKeyin interfaceMap<String,Object>- Overrides:
containsKeyin classHashMap<String,Object>- Parameters:
key- the key whose presence in this map is to be tested
-
getOrDefault
public Object getOrDefault(String key, Object defaultValue)
- Parameters:
key- the key whose associated value is to be returneddefaultValue- the default mapping of the key
-
getOrDefault
public Object getOrDefault(Object key, Object defaultValue)
- Specified by:
getOrDefaultin interfaceMap<String,Object>- Overrides:
getOrDefaultin classLinkedHashMap<String,Object>- Parameters:
key- the key whose associated value is to be returneddefaultValue- the default mapping of the key- Since:
- 2.0.2
-
forEchArrayObject
public void forEchArrayObject(String key, Consumer<JSONObject> action)
- Parameters:
key-action-- Since:
- 2.0.52
-
getJSONArray
public JSONArray getJSONArray(String key)
Returns theJSONArrayof the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
JSONArrayor null
-
getList
public <T> List<T> getList(String key, Class<T> itemClass, JSONReader.Feature... features)
-
getJSONObject
public JSONObject getJSONObject(String key)
Returns theJSONObjectof the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
JSONObjector null
-
getString
public String getString(String key)
Returns theStringof the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
Stringor null
-
getDouble
public Double getDouble(String key)
Returns theDoubleof the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
Doubleor null- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable doubleJSONException- Unsupported type conversion toDouble
-
getDoubleValue
public double getDoubleValue(String key)
Returns a double value of the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
- double
- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable doubleJSONException- Unsupported type conversion to double value
-
getFloat
public Float getFloat(String key)
Returns theFloatof the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
Floator null- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable floatJSONException- Unsupported type conversion toFloat
-
getFloatValue
public float getFloatValue(String key)
Returns a float value of the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
- float
- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable floatJSONException- Unsupported type conversion to float value
-
getLong
public Long getLong(String key)
Returns theLongof the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
Longor null- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable longJSONException- Unsupported type conversion toLong
-
getLongValue
public long getLongValue(String key)
Returns a long value of the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
- long
- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable longJSONException- Unsupported type conversion to long value
-
getLongValue
public long getLongValue(String key, long defaultValue)
Returns a long value of the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returneddefaultValue- the default mapping of the key- Returns:
- long
- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable longJSONException- Unsupported type conversion to long value
-
getInteger
public Integer getInteger(String key)
Returns theIntegerof the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
Integeror null- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable intJSONException- Unsupported type conversion toInteger
-
getIntValue
public int getIntValue(String key)
Returns an int value of the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
- int
- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable intJSONException- Unsupported type conversion to int value
-
getIntValue
public int getIntValue(String key, int defaultValue)
Returns an int value of the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returneddefaultValue- the default mapping of the key- Returns:
- int
- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable intJSONException- Unsupported type conversion to int value
-
getShort
public Short getShort(String key)
Returns theShortof the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
Shortor null- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable shortJSONException- Unsupported type conversion toShort
-
getShortValue
public short getShortValue(String key)
Returns a short value of the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
- short
- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable shortJSONException- Unsupported type conversion to short value
-
getByte
public Byte getByte(String key)
Returns theByteof the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
Byteor null- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable byteJSONException- Unsupported type conversion toByte
-
getByteValue
public byte getByteValue(String key)
Returns a byte value of the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
- byte
- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable byteJSONException- Unsupported type conversion to byte value
-
getBytes
public byte[] getBytes(String key)
-
getBoolean
public Boolean getBoolean(String key)
Returns theBooleanof the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
Booleanor null- Throws:
JSONException- Unsupported type conversion toBoolean
-
getBooleanValue
public boolean getBooleanValue(String key)
Returns a boolean value of the associated key in this object.- Parameters:
key- the key whose associated value is to be returned- Returns:
- boolean
- Throws:
JSONException- Unsupported type conversion to boolean value
-
getBooleanValue
public boolean getBooleanValue(String key, boolean defaultValue)
Returns a boolean value of the associated key in this object.- Parameters:
key- the key whose associated value is to be returneddefaultValue- the default mapping of the key- Returns:
- boolean
- Throws:
JSONException- Unsupported type conversion to boolean value
-
getBigInteger
public BigInteger getBigInteger(String key)
Returns theBigIntegerof the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
BigIntegeror null- Throws:
JSONException- Unsupported type conversion toBigIntegerNumberFormatException- If the value of get isStringand it is not a valid representation ofBigInteger
-
getBigDecimal
public BigDecimal getBigDecimal(String key)
Returns theBigDecimalof the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
BigDecimalor null- Throws:
JSONException- Unsupported type conversion toBigDecimalNumberFormatException- If the value of get isStringand it is not a valid representation ofBigDecimal
-
getDate
public Date getDate(String key)
Returns theDateof the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
Dateor null
-
getInstant
public Instant getInstant(String key)
Returns theBigIntegerof the associated keys in thisJSONObject.- Parameters:
key- the key whose associated value is to be returned- Returns:
BigIntegeror null
-
toString
public String toString()
Serialize to JSONString- Overrides:
toStringin classAbstractMap<String,Object>- Returns:
- JSON
String
-
toString
public String toString(JSONWriter.Feature... features)
Serialize to JSONString- Parameters:
features- features to be enabled in serialization- Returns:
- JSON
String
-
toJSONString
public String toJSONString(JSONWriter.Feature... features)
Serialize to JSONString- Parameters:
features- features to be enabled in serialization- Returns:
- JSON
String
-
toJSONString
public static String toJSONString(Object object, JSONWriter.Feature... features)
Serialize Java Object to JSONStringwith specifiedJSONReader.Features enabled- Parameters:
object- Java Object to be serialized into JSONStringfeatures- features to be enabled in serialization- Since:
- 2.0.6
-
toJSONBBytes
public byte[] toJSONBBytes(JSONWriter.Feature... features)
Serialize to JSONB bytes- Parameters:
features- features to be enabled in serialization- Returns:
- JSONB bytes
-
to
public <T> T to(Function<JSONObject,T> function)
- Since:
- 2.0.4
-
to
public <T> T to(Type type, JSONReader.Feature... features)
Convert thisJSONObjectto the specified ObjectJSONObject obj = ... Map<String, User> users = obj.to(new TypeReference<HashMap<String, User>>(){}.getType());- Parameters:
type- specify theTypeto be convertedfeatures- features to be enabled in parsing- Since:
- 2.0.4
-
to
public <T> T to(TypeReference<T> typeReference, JSONReader.Feature... features)
Convert thisJSONObjectto the specified ObjectJSONObject obj = ... Map<String, User> users = obj.to(new TypeReference<HashMap<String, User>>(){});- Parameters:
typeReference- specify theTypeReferenceto be convertedfeatures- features to be enabled in parsing- Since:
- 2.0.7
-
to
public <T> T to(Class<T> clazz, JSONReader.Feature... features)
Convert thisJSONObjectto the specified ObjectJSONObject obj = ... User user = obj.to(User.class);- Parameters:
clazz- specify theClass<T>to be convertedfeatures- features to be enabled in parsing- Since:
- 2.0.4
-
copyTo
public void copyTo(Object object, JSONReader.Feature... features)
-
toJavaObject
public <T> T toJavaObject(Class<T> clazz, JSONReader.Feature... features)
Convert thisJSONObjectto the specified Object- Parameters:
clazz- specify theClass<T>to be convertedfeatures- features to be enabled in parsing
-
toJavaObject
public <T> T toJavaObject(Type type, JSONReader.Feature... features)
Deprecated.since 2.0.4, please useto(Type, JSONReader.Feature...)Convert thisJSONObjectto the specified Object- Parameters:
type- specify theTypeto be convertedfeatures- features to be enabled in parsing
-
toJavaObject
public <T> T toJavaObject(TypeReference<T> typeReference, JSONReader.Feature... features)
Deprecated.since 2.0.4, please useto(Type, JSONReader.Feature...)Convert thisJSONObjectto the specified Object- Parameters:
typeReference- specify theTypeReferenceto be convertedfeatures- features to be enabled in parsing
-
getObject
public <T> T getObject(String key, Class<T> type, JSONReader.Feature... features)
Returns the result of theTypeconverter conversion of the associated value in thisJSONObject.User user = jsonObject.getObject("user", User.class);- Parameters:
key- the key whose associated value is to be returnedtype- specify theClassto be converted- Returns:
<T>or null- Throws:
JSONException- If no suitable conversion method is found
-
getObject
public <T> T getObject(String key, Type type, JSONReader.Feature... features)
Returns the result of theTypeconverter conversion of the associated value in thisJSONObject.User user = jsonObject.getObject("user", User.class);- Parameters:
key- the key whose associated value is to be returnedtype- specify theTypeto be convertedfeatures- features to be enabled in parsing- Returns:
<T>ornull- Throws:
JSONException- If no suitable conversion method is found
-
getObject
public <T> T getObject(String key, TypeReference<T> typeReference, JSONReader.Feature... features)
Returns the result of theTypeconverter conversion of the associated value in thisJSONObject.User user = jsonObject.getObject("user", User.class);- Parameters:
key- the key whose associated value is to be returnedtypeReference- specify theTypeReferenceto be convertedfeatures- features to be enabled in parsing- Returns:
<T>ornull- Throws:
JSONException- If no suitable conversion method is found- Since:
- 2.0.3
-
getObject
public <T> T getObject(String key, Function<JSONObject,T> creator)
- Since:
- 2.0.4
-
invoke
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
- Specified by:
invokein interfaceInvocationHandler- Parameters:
proxy- proxy object, currently uselessmethod- methods that need reflectionargs- parameters of invoke- Throws:
UnsupportedOperationException- If reflection for this method is not supportedArrayIndexOutOfBoundsException- If the length of args does not match the length of the method parameterThrowable
-
putObject
public JSONObject putObject(String name)
-
fluentPut
public JSONObject fluentPut(String key, Object value)
Chained addition of elementsJSONObject object = new JSONObject().fluentPut("a", 1).fluentPut("b", 2).fluentPut("c", 3);- Parameters:
key- key with which the specified value is to be associatedvalue- value to be associated with the specified key
-
isValid
public boolean isValid(JSONSchema schema)
- Since:
- 2.0.4
-
valueFilter
public void valueFilter(ValueFilter valueFilter)
- Since:
- 2.0.3
-
nameFilter
public void nameFilter(NameFilter nameFilter)
- Since:
- 2.0.3
-
clone
public JSONObject clone()
- Overrides:
clonein classHashMap<String,Object>- See Also:
JSONObject(Map)
-
eval
public Object eval(JSONPath path)
- See Also:
JSONPath.paths(Object)
-
getSize
public int getSize(String key)
if value instance of Map or Collection, return size, other return 0- Parameters:
key-- Since:
- 2.0.24
-
of
public static JSONObject of()
JSONObject jsonObject = JSONObject.of();
-
of
public static JSONObject of(String key, Object value)
Pack a pair of key-values asJSONObjectJSONObject jsonObject = JSONObject.of("name", "fastjson2");- Parameters:
key- the key of the elementvalue- the value of the element
-
of
public static JSONObject of(String k1, Object v1, String k2, Object v2)
Pack two key-value pairs asJSONObjectJSONObject jsonObject = JSONObject.of("key1", "value1", "key2", "value2");- Parameters:
k1- first keyv1- first valuek2- second keyv2- second value- Since:
- 2.0.2
-
of
public static JSONObject of(String k1, Object v1, String k2, Object v2, String k3, Object v3)
Pack three key-value pairs asJSONObjectJSONObject jsonObject = JSONObject.of("key1", "value1", "key2", "value2", "key3", "value3");- Parameters:
k1- first keyv1- first valuek2- second keyv2- second valuek3- third keyv3- third value- Since:
- 2.0.2
-
of
public static JSONObject of(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4)
Pack three key-value pairs asJSONObjectJSONObject jsonObject = JSONObject.of("key1", "value1", "key2", "value2", "key3", "value3", "key4", "value4");- Parameters:
k1- first keyv1- first valuek2- second keyv2- second valuek3- third keyv3- third valuek4- four keyv4- four value- Since:
- 2.0.8
-
of
public static JSONObject of(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5)
Pack three key-value pairs asJSONObjectJSONObject jsonObject = JSONObject.of("key1", "value1", "key2", "value2", "key3", "value3", "key4", "value4", "key5", "value5");- Parameters:
k1- first keyv1- first valuek2- second keyv2- second valuek3- third keyv3- third valuek4- four keyv4- four valuek5- five keyv5- five value- Since:
- 2.0.21
-
parseObject
public static <T> T parseObject(String text, Class<T> objectClass)
SeeJSON.parseObject(java.lang.String)for details
-
parseObject
public static <T> T parseObject(String text, Class<T> objectClass, JSONReader.Feature... features)
SeeJSON.parseObject(java.lang.String)for details
-
parseObject
public static <T> T parseObject(String text, Type objectType, JSONReader.Feature... features)
SeeJSON.parseObject(java.lang.String)for details
-
parseObject
public static <T> T parseObject(String text, TypeReference<T> typeReference, JSONReader.Feature... features)
SeeJSON.parseObject(java.lang.String)for details
-
parseObject
public static JSONObject parseObject(String text)
SeeJSON.parseObject(java.lang.String)for details
-
parse
public static JSONObject parse(String text, JSONReader.Feature... features)
SeeJSON.parse(java.lang.String)for details- Since:
- 2.0.13
-
from
public static JSONObject from(Object obj)
SeeJSON.toJSON(java.lang.Object)for details
-
from
public static JSONObject from(Object obj, JSONWriter.Feature... writeFeatures)
SeeJSON.toJSON(java.lang.Object)for details
-
-