java.lang.Object
io.helidon.json.JsonValue
io.helidon.json.JsonObject
Represents a JSON object value containing key-value pairs.
This module is incubating. These APIs may change in any version of Helidon, including backward incompatible changes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for creating JsonObject instances with a fluent API. -
Method Summary
Modifier and TypeMethodDescriptionarrayValue(String key) Return the JsonArray value associated with the specified key as an Optional.arrayValue(String key, JsonArray defaultValue) Return the JsonArray value associated with the specified key, or the default value if the key is not present.booleanValue(String key) Return the boolean value associated with the specified key as an Optional.booleanbooleanValue(String key, boolean defaultValue) Return the boolean value associated with the specified key, or the default value if the key is not present.static JsonObject.Builderbuilder()Create a new JsonObject.Builder for fluent construction of JsonObject instances.booleancontainsKey(String key) Checks if this object contains the specified key.static JsonObjectCreate a JsonObject from a map of string keys to JsonValue instances.doubleValue(String key) Return the double value associated with the specified key as an Optional.doubledoubleValue(String key, double defaultValue) Return the double value associated with the specified key, or the default value if the key is not present.static JsonObjectempty()Returns the shared empty JSON object instance.booleaninthashCode()Return the integer value associated with the specified key as an Optional.intReturn the integer value associated with the specified key, or the default value if the key is not present.keys()Return a set of all keys in this object as JsonString instances.Return a set of all keys in this object as String instances.numberValue(String key) Return the BigDecimal value associated with the specified key as an Optional.numberValue(String key, BigDecimal defaultValue) Return the BigDecimal value associated with the specified key, or the default value if the key is not present.objectValue(String key) Return the JsonObject value associated with the specified key as an Optional.objectValue(String key, JsonObject defaultValue) Return the JsonObject value associated with the specified key, or the default value if the key is not present.intsize()Return the number of properties in this object.stringValue(String key) Return the string value associated with the specified key as an Optional.stringValue(String key, String defaultValue) Return the string value associated with the specified key, or the default value if the key is not present.voidtoJson(JsonGenerator generator) Write this JSON value to the provided generator.type()Return the type of this JSON value.Return the value associated with the specified key, or the default value if the key is not present.
-
Method Details
-
builder
Create a new JsonObject.Builder for fluent construction of JsonObject instances.- Returns:
- a new JsonObject.Builder
-
create
Create a JsonObject from a map of string keys to JsonValue instances.- Parameters:
content- the map containing the object properties- Returns:
- a new JsonObject
-
empty
Returns the shared empty JSON object instance.- Returns:
- the empty JSON object
-
containsKey
Checks if this object contains the specified key.- Parameters:
key- the key to check for- Returns:
- true if the object contains the key, false otherwise
-
value
Return the value associated with the specified key, or the default value if the key is not present.- Parameters:
key- the key to look updefaultValue- the value to return if the key is not present- Returns:
- the value associated with the key, or the default value
-
booleanValue
Return the boolean value associated with the specified key as an Optional.- Parameters:
key- the key to look up- Returns:
- an Optional containing the boolean value, or empty if the key is not present
-
booleanValue
Return the boolean value associated with the specified key, or the default value if the key is not present.- Parameters:
key- the key to look updefaultValue- the value to return if the key is not present- Returns:
- the boolean value associated with the key, or the default value
-
objectValue
Return the JsonObject value associated with the specified key as an Optional.- Parameters:
key- the key to look up- Returns:
- an Optional containing the JsonObject value, or empty if the key is not present
-
objectValue
Return the JsonObject value associated with the specified key, or the default value if the key is not present.- Parameters:
key- the key to look updefaultValue- the value to return if the key is not present- Returns:
- the JsonObject value associated with the key, or the default value
-
stringValue
Return the string value associated with the specified key as an Optional.- Parameters:
key- the key to look up- Returns:
- an Optional containing the string value, or empty if the key is not present
-
stringValue
Return the string value associated with the specified key, or the default value if the key is not present.- Parameters:
key- the key to look updefaultValue- the value to return if the key is not present- Returns:
- the string value associated with the key, or the default value
-
intValue
Return the integer value associated with the specified key as an Optional.- Parameters:
key- the key to look up- Returns:
- an Optional containing the integer value, or empty if the key is not present
-
intValue
Return the integer value associated with the specified key, or the default value if the key is not present.- Parameters:
key- the key to look updefaultValue- the value to return if the key is not present- Returns:
- the integer value associated with the key, or the default value
-
doubleValue
Return the double value associated with the specified key as an Optional.- Parameters:
key- the key to look up- Returns:
- an Optional containing the double value, or empty if the key is not present
-
doubleValue
Return the double value associated with the specified key, or the default value if the key is not present.- Parameters:
key- the key to look updefaultValue- the value to return if the key is not present- Returns:
- the double value associated with the key, or the default value
-
numberValue
Return the BigDecimal value associated with the specified key as an Optional.- Parameters:
key- the key to look up- Returns:
- an Optional containing the BigDecimal value, or empty if the key is not present
-
numberValue
Return the BigDecimal value associated with the specified key, or the default value if the key is not present.- Parameters:
key- the key to look updefaultValue- the value to return if the key is not present- Returns:
- the BigDecimal value associated with the key, or the default value
-
arrayValue
Return the JsonArray value associated with the specified key as an Optional.- Parameters:
key- the key to look up- Returns:
- an Optional containing the JsonArray value, or empty if the key is not present
-
arrayValue
Return the JsonArray value associated with the specified key, or the default value if the key is not present.- Parameters:
key- the key to look updefaultValue- the value to return if the key is not present- Returns:
- the JsonArray value associated with the key, or the default value
-
keys
Return a set of all keys in this object as JsonString instances.- Returns:
- a set of JsonString keys
-
keysAsStrings
Return a set of all keys in this object as String instances.- Returns:
- a set of String keys
-
size
public int size()Return the number of properties in this object.- Returns:
- the size of this object
-
type
Description copied from class:JsonValueReturn the type of this JSON value. -
toJson
Description copied from class:JsonValueWrite this JSON value to the provided generator. -
hashCode
public int hashCode() -
equals
-