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 class
Represents a JSON array.static final class
A single JSON value. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if this object contains the given key.static JSON
empty()
Returns aJSON
of an empty document.Returns theJSON.Value
of the given key.getFeature
(String key) Returns theJSON.Value
of the given key.keySet()
Returns a set of all keys of this object.static JSON
parse
(InputStream in) Parses JSON from anInputStream
.static JSON
Parses 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
-InputStream
to read from. Will be closed after use.- Returns:
JSON
of the read content.- Throws:
IOException
-
parse
Parses JSON from a String.- Parameters:
json
- JSON string- Returns:
JSON
of the read content.
-
empty
Returns aJSON
of an empty document.- Returns:
- Empty
JSON
-
keySet
Returns a set of all keys of this object.- Returns:
Set
of keys
-
contains
Checks if this object contains the given key.- Parameters:
key
- Name of the key to check- Returns:
true
if the key is present
-
get
Returns theJSON.Value
of the given key.- Parameters:
key
- Key to read- Returns:
JSON.Value
of the key
-
getFeature
Returns theJSON.Value
of the given key.- Parameters:
key
- Key to read- Returns:
JSON.Value
of 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
-