Giter VIP home page Giter VIP logo

json-rpc's Introduction

System.Data.JsonRpc

Provides support for serializing and deserializing JSON-RPC 2.0 messages.

NuGet package

Features

  • The serializer supports transparent usage of number and string message identifiers.
  • The serializer supports dynamic response type contracts when result data type depends on method parameters.

Specifics

The serializer is used as a stateful instance. Due to the JSON-RPC protocol nuances, deserializing a response requires more than only defining a response contract. Before deserializing a caller must specify a request identifier mapping to the corresponding method name (static bindings), or specify a request identifier mapping to the corresponding response contract (dynamic bindings). The serializer supports disposing for clearing all active bindings.

Compatibility

As recommended in the specification, the serializer provides backward compatibility for JSON-RPC 1.0 messages, limited to the intersection of JSON-RPC 1.0 and JSON-RPC 2.0 requirements and the API. As an example, the serializer can be used for serializing and deserializing Bitcoin protocol messages, according to the "Bitcoin Core APIs - Remote Procedure Calls" documentation. To enable JSON-RPC 1.0 compatibility, a caller must change the compatibility level on a serializer instance.

Examples

  • Communication with a JSON-RPC 2.0 server:
var serializer = new JsonRpcSerializer();
var request = new JsonRpcRequest("sum", 1L, new[] { 1, 2 });
var requestString = serializer.SerializeRequest(request);

// [Sending an HTTP request and storing a response string in the "responseString"]

serializer.ResponseContracts["sum"] = new JsonRpcResponseContract(typeof(int));
serializer.StaticResponseBindings[request.Id] = "sum";

var responseData = serializer.DeserializeResponseData(responseString);
var result = (int)responseData.Item.Message.Result;

json-rpc's People

Contributors

alexanderkozlenko avatar mazur-k avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.