Show / Hide Table of Contents

    Class JsonRpcResponse<TResult>

    a JSON-RPC server response which may either indicate success, with an arbitrary response object, or an error with a corresponding JsonRpcError instance describing the error.
    Inheritance
    Object
    JsonRpcMessage
    JsonRpcResponse<TResult>
    JsonRpcResponse
    Implements
    IJsonRpcResponse<TResult>
    IJsonRpcMessage
    IHasProtocolVersion
    Inherited Members
    JsonRpcMessage.IdJsonPropertyName
    JsonRpcMessage.ShouldSerializeId()
    JsonRpcMessage.Id
    Namespace: XploRe.Net.JsonRpc
    Assembly: XploRe.Net.JsonRpc.dll
    Syntax
    public class JsonRpcResponse<TResult> : JsonRpcMessage, IJsonRpcResponse<TResult>, IJsonRpcMessage, IHasProtocolVersion
    Type Parameters
    Name Description
    TResult The expected type of the response result on success. If the result returned by the server cannot be converted to the requested type, a Newtonsoft.Json.JsonSerializationException is thrown.

    The conversion is directly performed during JSON deserialisation and respects all Newtonsoft.Json attributes and serialisation settings.

    Remarks
    The Error and Result properties are mutually exclusive. If the response indicates an error, the Error property is set to a JsonRpcError instance with details on the error. Otherwise, the Error property is null and omitted in the payload; the Result property must exist in the payload but may be null.

    Constructors

    Name Description
    JsonRpcResponse(JsonRpcId, String, JsonRpcError, TResult) Initialises a new XploRe.Net.JsonRpc.JsonRpcResponse{TResult} instance.
    JsonRpcResponse(JsonRpcId, JsonRpcError, TResult) Initialises a new XploRe.Net.JsonRpc.JsonRpcResponse{TResult} instance.

    Fields

    Name Description
    ErrorJsonPropertyName JSON-RPC payload property name of the Error property.
    ProtocolVersionJsonPropertyName JSON-RPC payload property name of the ProtocolVersion property.
    ResultJsonPropertyName JSON-RPC payload property name of the Result property.

    Properties

    Name Description
    Default A JSON-RPC response object that indicates success but has a default result value (null for a class result type) and the Null JSON-RPC ID.
    Error Set to the JsonRpcError instance if an error occured during the JSON-RPC request. If the request succeeded, this property is null.
    ProtocolVersion The JSON-RPC version of the response.
    Result The arbitrary JSON-RPC result object. May be null. If an error occurred, this property is always null. To test for an error indication, use the XploRe.Net.JsonRpc.JsonRpcResponse`1.IsError property.

    Methods

    Name Description
    ShouldSerializeResult() Controls serialisation of the Result property. The error property is required in the payload if the response indicates success; the result may be null.

    See Also

    JSON-RPC 2.0 Specification: Response Object
    Back to top Copyright © 2017-2018, xplo.re IT Services, Michael Maier. All rights reserved.