Package org.javalite.json
Class JSONMap
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<String,Object>
- 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
-
Method Summary
Modifier and TypeMethodDescriptionReturns an object deep from the structure of a JSON document.getBigDecimal(String attributePath)
getBoolean(String attributePath)
getInteger(String attributePath)
Returns a list deep from the structure of JSON document.Returns a map deep from the structure of a JSON document.toJSON()
toJSON(boolean pretty)
toString()
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
Methods inherited from class java.util.AbstractMap
equals, hashCode
-
Constructor Details
-
JSONMap
-
JSONMap
Creates a ne instance from the array, where odd arguments are map keys and the even are values.- Parameters:
keysAndValues
- keys and
-
JSONMap
public JSONMap()
-
-
Method Details
-
get
Returns an object deep from the structure of a JSON document.{ "university": { students : { "mary" : { "first_name": "Mary", "last_name": "Smith", }, "joe" : { "first_name": "Joe", "last_name": "Shmoe", } } } }
-
getMap
Returns a map deep from the structure of a JSON document.{ "university": { students : { "mary" : { "first_name": "Mary", "last_name": "Smith", }, "joe" : { "first_name": "Joe", "last_name": "Shmoe", } } } }
- Parameters:
attributePath
- accepts a dot-delimited format: "university.students.joe" where every entry must be a map- Returns:
- a map from the depths of the JSON structure.
-
getList
Returns a list deep from the structure of JSON document.{ "university": { students : ["mary", joe] } }
- Parameters:
attributePath
- accepts a dot-delimited format: "university.students" where every entry must be a map- Returns:
- list from the depths of the JSON structure.
-
getBoolean
- Parameters:
attributePath
- accepts a dot-delimited format: "university.students" where every entry must be a map.
-
getBigDecimal
- Parameters:
attributePath
- accepts a dot-delimited format: "university.students" where every entry must be a map.
-
getDate
- Parameters:
attributePath
- accepts a dot-delimited format: "university.students" where every entry must be a map.
-
getDouble
- Parameters:
attributePath
- accepts a dot-delimited format: "university.students" where every entry must be a map.
-
getFloat
- Parameters:
attributePath
- accepts a dot-delimited format: "university.students" where every entry must be a map.
-
getInteger
- Parameters:
attributePath
- accepts a dot-delimited format: "university.students" where every entry must be a map.
-
getLong
- Parameters:
attributePath
- accepts a dot-delimited format: "university.students" where every entry must be a map.
-
getShort
- Parameters:
attributePath
- accepts a dot-delimited format: "university.students" where every entry must be a map.
-
getString
- Parameters:
attributePath
- accepts a dot-delimited format: "university.students" where every entry must be a map.
-
toString
- Overrides:
toString
in classAbstractMap<String,Object>
- Returns:
- a JSON representation of this object
-
toJSON
- Parameters:
pretty
- - true for formatted JSON.- Returns:
- a JSON representation of this object
-
toJSON
- Returns:
- a JSON representation of this object
-