java.lang.Object
org.shredzone.acme4j.toolbox.JSON
- All Implemented Interfaces:
Serializable
A model containing a JSON result. The content is immutable.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRepresents a JSON array.static final classA single JSON value. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if this object contains the given key.static JSONempty()Returns aJSONof an empty document.static JSONCreates a JSON object from a map.Returns theJSON.Valueof the given key.getFeature(String key) Returns theJSON.Valueof the given key.keySet()Returns a set of all keys of this object.static JSONparse(InputStream in) Parses JSON from anInputStream.static JSONParses JSON from a String.toMap()Returns the content as unmodifiable Map.toString()Returns the content as JSON string.
-
Method Details
-
parse
Parses JSON from anInputStream.- Parameters:
in-InputStreamto read from. Will be closed after use.- Returns:
JSONof the read content.- Throws:
IOException
-
parse
Parses JSON from a String.- Parameters:
json- JSON string- Returns:
JSONof the read content.
-
fromMap
Creates a JSON object from a map.The map's content is deeply copied. Changes to the map won't reflect in the created JSON structure.
- Parameters:
data- Map structure- Returns:
JSONof the map's content.- Since:
- 3.2.0
-
empty
Returns aJSONof an empty document.- Returns:
- Empty
JSON
-
keySet
Returns a set of all keys of this object.- Returns:
Setof keys
-
contains
Checks if this object contains the given key.- Parameters:
key- Name of the key to check- Returns:
trueif the key is present
-
get
Returns theJSON.Valueof the given key.- Parameters:
key- Key to read- Returns:
JSON.Valueof the key
-
getFeature
Returns theJSON.Valueof the given key.- Parameters:
key- Key to read- Returns:
JSON.Valueof the key- Throws:
AcmeNotSupportedException- if the key is not present. The key is used as feature name.
-
toString
Returns the content as JSON string. -
toMap
Returns the content as unmodifiable Map.- Since:
- 2.8
-