Interface JsonRpcResult


public interface JsonRpcResult
A representation of a JSON-RPC response result.
  • Method Details

    • create

      static JsonRpcResult create(JsonValue result)
      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

      JsonValue get(String name)
      Get a JSON object property value as a JSON value.
      Parameters:
      name - property name
      Returns:
      the property value
      Throws:
      ClassCastException - if not a JSON object
      IllegalArgumentException - if the property does not exist
    • getString

      String getString(String name)
      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 string
      IllegalArgumentException - if the property does not exist
    • find

      Optional<JsonValue> find(String name)
      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

      JsonValue get(int index)
      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 array
      IndexOutOfBoundsException - if index is out of bounds
    • getString

      String getString(int index)
      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 string
      IndexOutOfBoundsException - if index is out of bounds
    • find

      Optional<JsonValue> find(int index)
      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 string
      IndexOutOfBoundsException - if index is out of bounds
    • as

      <T> T as(Class<T> type)
      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