Class ApiJsonParser
java.lang.Object
io.helidon.integrations.common.rest.ApiJsonParser
- Direct Known Subclasses:
ApiResponse,CertificateGet.Response,DbGet.Response,Encrypt.Encrypted,GetCubbyhole.Response,GetKv1.Response,GetKv2.Response,Kv2Metadata,ListSecrets.Response
Helper methods to process a returned JSON.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionisPresent(JsonObject json, String name) If the property is present on the JSON object, returns a non-empty optional, otherwise returns an empty.isPresent(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.protected static StringstringValue(JsonValue value) Get a string value from a json value.protected static StringstringValue(JsonValue value) Deprecated, for removal: This API element is subject to removal in a future version.toBoolean(JsonObject json, String name) Get a boolean value.toBoolean(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.protected static Optional<byte[]> toBytesBase64(JsonObject json, String name) Get bytes from a base64 string value.protected static Optional<byte[]> toBytesBase64(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.toDouble(JsonObject json, String name) Get a double value.toDouble(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.toInstant(JsonObject json, String name, DateTimeFormatter formatter) Get anInstantvalue.toInstant(JsonObject json, String name, DateTimeFormatter formatter) Deprecated, for removal: This API element is subject to removal in a future version.toInt(JsonObject json, String name) Get an int value.toInt(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.toList(JsonObject json, String name) Convert a JSON array in the JSON object to a list of strings.toList(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.toLong(JsonObject json, String name) Get a long value.toLong(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.toMap(JsonObject json, String name) Get a map value.toMap(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.protected static Optional<JsonObject> toObject(JsonObject json, String name) Get a child JSON object.protected static Optional<JsonObject> toObject(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.toString(JsonObject json, String name) Get a string value.toString(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.
-
Constructor Details
-
ApiJsonParser
public ApiJsonParser()
-
-
Method Details
-
stringValue
Get a string value from a json value.- Parameters:
value- Json value- Returns:
- string representation of the value.
- Throws:
ApiException- in case the value is array or object
-
stringValue
Deprecated, for removal: This API element is subject to removal in a future version.Get a string value from a JSON-P value.- Parameters:
value- Json value- Returns:
- string representation of the value
-
toList
Convert a JSON array in the JSON object to a list of strings.- Parameters:
json- JSON objectname- name of the array in the object- Returns:
- list from the array, or empty if the array does not exist or is null
-
toList
@Deprecated(since="4.5.0", forRemoval=true) protected static List<String> toList(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.Convert a JSON-P array in the JSON object to a list of strings.- Parameters:
json- JSON objectname- name of the array in the object- Returns:
- list from the array, or empty if the array does not exist or is null
-
toBytesBase64
Get bytes from a base64 string value.- Parameters:
json- JSON objectname- name of the property- Returns:
- bytes or empty if the property does not exist or is null
-
toBytesBase64
@Deprecated(since="4.5.0", forRemoval=true) protected static Optional<byte[]> toBytesBase64(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.Get bytes from a base64 string value.- Parameters:
json- JSON objectname- name of the property- Returns:
- bytes or empty if the property does not exist or is null
-
toObject
Get a child JSON object.- Parameters:
json- JSON objectname- name of the property- Returns:
- JSON object or empty if the property does not exist or is null
-
toObject
@Deprecated(since="4.5.0", forRemoval=true) protected static Optional<JsonObject> toObject(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.Get a child JSON-P object.- Parameters:
json- JSON objectname- name of the property- Returns:
- JSON object or empty if the property does not exist or is null
-
toString
Get a string value.- Parameters:
json- JSON objectname- name of the property- Returns:
- string or empty if the property does not exist or is null
-
toString
@Deprecated(since="4.5.0", forRemoval=true) protected static Optional<String> toString(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.Get a string value.- Parameters:
json- JSON objectname- name of the property- Returns:
- string or empty if the property does not exist or is null
-
toInt
Get an int value.- Parameters:
json- JSON objectname- name of the property- Returns:
- int or empty if the property does not exist or is null
-
toInt
@Deprecated(since="4.5.0", forRemoval=true) protected static Optional<Integer> toInt(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.Get an int value.- Parameters:
json- JSON objectname- name of the property- Returns:
- int or empty if the property does not exist or is null
-
toLong
Get a long value.- Parameters:
json- JSON objectname- name of the property- Returns:
- long or empty if the property does not exist or is null
-
toLong
@Deprecated(since="4.5.0", forRemoval=true) protected static Optional<Long> toLong(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.Get a long value.- Parameters:
json- JSON objectname- name of the property- Returns:
- long or empty if the property does not exist or is null
-
toDouble
Get a double value.- Parameters:
json- JSON objectname- name of the property- Returns:
- double or empty if the property does not exist or is null
-
toDouble
@Deprecated(since="4.5.0", forRemoval=true) protected static Optional<Double> toDouble(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.Get a double value.- Parameters:
json- JSON objectname- name of the property- Returns:
- double or empty if the property does not exist or is null
-
toBoolean
Get a boolean value.- Parameters:
json- JSON objectname- name of the property- Returns:
- boolean or empty if the property does not exist or is null
-
toBoolean
@Deprecated(since="4.5.0", forRemoval=true) protected static Optional<Boolean> toBoolean(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.Get a boolean value.- Parameters:
json- JSON objectname- name of the property- Returns:
- boolean or empty if the property does not exist or is null
-
toInstant
protected static Optional<Instant> toInstant(JsonObject json, String name, DateTimeFormatter formatter) Get anInstantvalue.- Parameters:
json- JSON objectname- name of the propertyformatter- to use when parsing the string value- Returns:
- instant or empty if the property does not exist or is null
-
toInstant
@Deprecated(since="4.5.0", forRemoval=true) protected static Optional<Instant> toInstant(JsonObject json, String name, DateTimeFormatter formatter) Deprecated, for removal: This API element is subject to removal in a future version.Get anInstantvalue.- Parameters:
json- JSON objectname- name of the propertyformatter- to use when parsing the string value- Returns:
- instant or empty if the property does not exist or is null
-
toMap
Get a map value.- Parameters:
json- JSON objectname- name of the property- Returns:
- map with property key/value pairs, or empty if the property does not exist or is null
-
toMap
@Deprecated(since="4.5.0", forRemoval=true) protected static Map<String,String> toMap(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.Get a map value.- Parameters:
json- JSON objectname- name of the property- Returns:
- map with property key/value pairs, or empty if the property does not exist or is null
-
isPresent
If the property is present on the JSON object, returns a non-empty optional, otherwise returns an empty.- Parameters:
json- JSON objectname- name of the property- Returns:
- non-empty optional if the property exists and is not null
-
isPresent
@Deprecated(since="4.5.0", forRemoval=true) protected static Optional<Boolean> isPresent(JsonObject json, String name) Deprecated, for removal: This API element is subject to removal in a future version.If the property is present on the JSON-P object, returns a non-empty optional.- Parameters:
json- JSON objectname- name of the property- Returns:
- non-empty optional if the property exists and is not null
-
isPresent(JsonObject, String)