Package org.ghotibeaun.json
Interface JSONMapNode
- All Superinterfaces:
Comparable<JSONNode>
,JSONNode
,Serializable
- All Known Subinterfaces:
JSONObject
public interface JSONMapNode extends JSONNode
-
Method Summary
Modifier and Type Method Description void
clear()
Clears all values from this mapped objectboolean
containsKey(String key)
Returns whether or not a named entry exists in the mapSet<Map.Entry<String,JSONValue<?>>>
elements()
Returns the set of the map's String, JSONValue pairsJSONValue<?>
get(String key)
Returns a value based on a specific keyMap<String,Object>
getMap()
Serializes the internal map's String, JSONValue<?> pairs into a generic map of String, Object pairs.default boolean
isNull(String key)
Returns if the specified key is null, or doesn't existIterable<String>
keys()
Iterator<String>
keySet()
String[]
names()
Returns an array of each entry's keysvoid
put(String key, Object value)
Adds a key-value pair to the map.void
put(String key, Object... value)
void
put(String key, JSONValue<?> value)
Add a key value pair to the map.void
putAll(Map<String,JSONValue<?>> map)
void
putAllRaw(Map<String,Object> map)
Imports a generic map and creates an internal map representation of String, JSONValue<?> pairsJSONValue<?>
remove(String key)
Removes an entry from the mapint
size()
returns the number of entries in this mapped object<V> List<V>
valueList()
Collection<JSONValue<?>>
values()
Returns an interable collection of all the map's valuesMethods inherited from interface java.lang.Comparable
compareTo
Methods 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
Add a key value pair to the map. If the named pair already exists, the value is updated- Parameters:
key
- the entry namevalue
- the JSONValue
-
put
Adds a key-value pair to the map. Values can be of any valid value type and will be converted to the appropriateJSONValue<?>
instance- Parameters:
key
- the entry namevalue
- the value- Throws:
JSONInvalidValueTypeException
- thrown if the value is not a valid value type (seeJSONValueType
)
-
put
-
putAll
- Parameters:
map
- A map of Key-JSONValue pairs
-
putAllRaw
Imports a generic map and creates an internal map representation of String, JSONValue<?> pairs- Parameters:
map
- the associative array map object containing the key value pairs to import- Throws:
JSONInvalidValueTypeException
- thrown if any of the values is not a valid value type (seeJSONValueType
)
-
clear
void clear()Clears all values from this mapped object -
size
int size()returns the number of entries in this mapped object- Returns:
- the size of the current map's entries
-
values
Collection<JSONValue<?>> values()Returns an interable collection of all the map's values- Returns:
- an iterable collection of all the maps values
-
valueList
-
keys
-
keySet
-
get
Returns a value based on a specific key- Parameters:
key
- the entry's key- Returns:
- the value of the entry
- Throws:
JSONValueNotFoundException
- thrown when the value is not found
-
getMap
Serializes the internal map's String, JSONValue<?> pairs into a generic map of String, Object pairs. Useful when you need to integrate with other code that doesn't work with JSONValue objects- Returns:
- a Map of String, Object pairs
-
elements
Returns the set of the map's String, JSONValue pairs- Returns:
- the set of the map's String, JSONValue pairs
-
names
String[] names()Returns an array of each entry's keys- Returns:
- a String array of each entry's keys
-
containsKey
Returns whether or not a named entry exists in the map- Parameters:
key
- the key to evaluate- Returns:
true
if the key exists;false
otherwise
-
remove
Removes an entry from the map- Parameters:
key
- the specified entry's key- Returns:
- The entry's value
-
isNull
Returns if the specified key is null, or doesn't exist- Parameters:
key
- the value key- Returns:
- true if the value for the key is null, or if the key doesn't exist
-