public interface JsonRpcResult
A representation of a JSON-RPC response result.
-
Method Summary
Modifier and TypeMethodDescription<T> TAccess a response result as a Java object.Access a response result as a JSON array.Access a response result as a JSON object.Access a response result as a JSON value.static JsonRpcResultCreate an instance from a JSON value.find(int index) Get a JSON array value by index as a string, if present.Get a JSON object property value as a string, if present.get(int index) Get a JSON array value by index as a JSON value.Get a JSON object property value as a JSON value.getString(int index) Get a JSON array value by index as a string.Get a JSON object property value as a string.
-
Method Details
-
create
Create an instance from a JSON value.- Parameters:
result- the value- Returns:
- a new instance of this class
-
asJsonObject
JsonObject asJsonObject()Access a response result as a JSON object.- Returns:
- a JSON object
- Throws:
ClassCastException- if not a JSON object
-
asJsonArray
JsonArray asJsonArray()Access a response result as a JSON array.- Returns:
- a JSON array
- Throws:
ClassCastException- if not a JSON array
-
asJsonValue
JsonValue asJsonValue()Access a response result as a JSON value.- Returns:
- a JSON structure
-
get
Get a JSON object property value as a JSON value.- Parameters:
name- property name- Returns:
- the property value
- Throws:
ClassCastException- if not a JSON objectIllegalArgumentException- if the property does not exist
-
getString
Get a JSON object property value as a string.- Parameters:
name- property name- Returns:
- the property value as a string
- Throws:
ClassCastException- if not a JSON object or value not a stringIllegalArgumentException- if the property does not exist
-
find
Get a JSON object property value as a string, if present.- Parameters:
name- property name- Returns:
- an optional property value
- Throws:
ClassCastException- if not a JSON object or value not a string
-
get
Get a JSON array value by index as a JSON value.- Parameters:
index- the index- Returns:
- the JSON value
- Throws:
ClassCastException- if not a JSON arrayIndexOutOfBoundsException- if index is out of bounds
-
getString
Get a JSON array value by index as a string.- Parameters:
index- the index- Returns:
- the property value as a string
- Throws:
ClassCastException- if not a JSON array or value not a stringIndexOutOfBoundsException- if index is out of bounds
-
find
Get a JSON array value by index as a string, if present.- Parameters:
index- the index- Returns:
- the optional property value as a string
- Throws:
ClassCastException- if not a JSON array or value not a stringIndexOutOfBoundsException- if index is out of bounds
-
as
Access a response result as a Java object. This method will bind the result using JSONB.- Type Parameters:
T- the bean type- Parameters:
type- the bean class- Returns:
- an instance of the bean type
- Throws:
JsonbException- if an error occurs during mapping
-