Provides support for serializing and deserializing JSON-RPC 2.0 messages.
Release | Current | |
---|---|---|
Artifacts | ||
Code Health | ||
Build Status |
- Supports dynamic response type contracts based on method parameters.
- Provides limited backward compatibility with the JSON-RPC 1.0 protocol.
var contracts = new JsonRpcContractResolver();
var serializer = new JsonRpcSerializer(contracts);
contracts.AddResponseContract("sum", new JsonRpcResponseContract(typeof(long)));
var request = new JsonRpcRequest(1L, "sum", new[] { 1L, 2L });
var requestString = serializer.SerializeRequest(request);
// ...
contracts.AddResponseBinding(request.Id, request.Method);
var responseData = serializer.DeserializeResponseData(responseString);
var response = responseData.Item.Message;
Console.WriteLine((long)response.Result);
- Client-side usage: https://github.com/alexanderkozlenko/json-rpc-client
- Server-side usage: https://github.com/alexanderkozlenko/aspnetcore-json-rpc