JsonRpcResponse

A Json-Rpc response with an id of type TId.

Constructors

this
this()

Members

Functions

isError
bool isError()

Tells if the response is an error.

isSuccess
bool isSuccess()

Tells if the response is in success.

toJson
Json toJson()

Convert to Json.

toString
string toString()

Convert to Json string.

Static functions

fromJson
JsonRpcResponse fromJson(Json src)

Parse from Json.

fromString
JsonRpcResponse fromString(string src)

Parse from Json string.

Variables

error
Nullable!JsonRpcError error;

Optional error.

id
Nullable!TId id;

id

jsonrpc
string jsonrpc;
result
Nullable!Json result;

Optional result.

Inherited Members

From IRpcResponse

toString
string toString()
Undocumented in source.

Examples

auto r1 = new JsonRpcResponse!int();
Json json = "hello";
r1.result = json;
r1.id = 42;
r1.toString().should == `{"result":"hello","id":42,"jsonrpc":"2.0"}`;

auto error = new JsonRpcError();
error.code = -32600;
error.message = "Invalid Request";

auto r2 = new JsonRpcResponse!int();
r2.error = error;
r2.id = 1;
r2.toString().should == `{"error":{"code":-32600,"message":"Invalid Request"},"id":1,"jsonrpc":"2.0"}`;

Meta