Package org.ghotibeaun.json
Interface JSONObject
- All Superinterfaces:
Comparable<JSONNode>,JSONMapNode,JSONNode,Serializable
public interface JSONObject extends JSONMapNode
A JSON Object consisting of a collection of key-value pairs
- Author:
- Jim Earley (xml.jim@gmail.com)
-
Method Summary
Modifier and Type Method Description booleangetBoolean(String key)Return a booleanintgetInt(String key)Return an integerJSONArraygetJSONArray(String key)Return a JSONArrayJSONObjectgetJSONObject(String key)Return a JSONObject with the associated keylonggetLong(String key)Return a long valueNumbergetNumber(String key)Return a Number.StringgetString(String key)Return a Stringdefault <T> TgetValue(String key)Return a casted valueJSONValueTypegetValueType(String key)Returns the JSON value typedefault voidmerge(JSONObject secondary, ArrayConflict arrayConflict, ObjectConflict objectConflict)Merge another JSONObject into this instance.default JSONObjectmergeToCopy(JSONObject secondary, ArrayConflict arrayConflict, ObjectConflict objectConflict)Merge the current JSONObject instance with another and return the merged instance.voidput(String key, boolean b)Adds or replaces a boolean valuevoidput(String key, Number n)Adds or replaces a number valuevoidput(String key, String s)Adds or replaces a String valuevoidput(String key, JSONArray a)Adds or replaces a JSONArray valuedefault voidput(String key, JSONNode node)Set a JSONNode (either a JSONObject or JSONArray)voidput(String key, JSONObject o)Adds or replaces a JSONObject valuevoidputNull(String key)Put a null value associated with a keyMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface org.ghotibeaun.json.JSONMapNode
clear, containsKey, elements, get, getMap, isNull, keys, keySet, names, put, put, put, putAll, putAllRaw, remove, size, valueList, valuesMethods inherited from interface org.ghotibeaun.json.JSONNode
asJSONArray, asJSONObject, isArray, isEquivalent, isObject, prettyPrint, prettyPrint, select, select, select, selectValue, selectValue, selectValue, toJSONString, write, write, write, write, write, write, write, write
-
Method Details
-
put
Adds or replaces a number value- Parameters:
key- the keyn- the number
-
put
Adds or replaces a String value- Parameters:
key- the keys- the string value
-
put
Adds or replaces a boolean value- Parameters:
key- the keyb- the boolean value
-
put
Set a JSONNode (either a JSONObject or JSONArray)- Parameters:
key- the keynode- the JSONNode
-
put
Adds or replaces a JSONArray value- Parameters:
key- the keya- the JSONArray
-
put
Adds or replaces a JSONObject value- Parameters:
key- the keyo- the JSONObject
-
putNull
Put a null value associated with a key- Parameters:
key- the key
-
getJSONObject
Return a JSONObject with the associated key- Parameters:
key- the key- Returns:
- a JSONObject
-
getJSONArray
Return a JSONArray- Parameters:
key- the key- Returns:
- a JSONArray
-
getNumber
Return a Number. Value can be cast to the appropriate underlying type- Parameters:
key- the key- Returns:
- a Number
-
getLong
Return a long value- Parameters:
key- the key- Returns:
- long value
-
getInt
Return an integer- Parameters:
key- the key- Returns:
- the integer value
-
getBoolean
Return a boolean- Parameters:
key- the key- Returns:
- the boolean value
-
getValueType
Returns the JSON value type- Parameters:
key- the key- Returns:
- the value type
-
getString
Return a String- Parameters:
key- the key- Returns:
- the String value
-
getValue
Return a casted value- Type Parameters:
T- The cast type- Parameters:
key- the key- Returns:
- the casted value
-
merge
default void merge(JSONObject secondary, ArrayConflict arrayConflict, ObjectConflict objectConflict)Merge another JSONObject into this instance.HERE THERE BE DRAGONS: Once the merge happens, the original Node value is replaced. Know your data
- Parameters:
secondary- the other JSONObject instance to mergearrayConflict- the Array Conflict Strategy to useobjectConflict- the Object Conflict Strategy to use
-
mergeToCopy
default JSONObject mergeToCopy(JSONObject secondary, ArrayConflict arrayConflict, ObjectConflict objectConflict)Merge the current JSONObject instance with another and return the merged instance. The original instance is left in its original state.- Parameters:
secondary- the other JSONObject instance to mergearrayConflict- the Array Conflict Strategy to useobjectConflict- the Object Conflict Strategy to use- Returns:
-