Table of Contents

Overview

Nerdbank.JsonRpc is a NativeAOT-safe .NET library for building strongly typed JSON-RPC clients and servers over MessagePack or UTF-8 JSON.

Install

dotnet add package Nerdbank.JsonRpc

NuGet package

Highlights

  • Typed RPC: Register server targets using PolyType method shapes and call methods through typed APIs. Get started.
  • Encodings and framing: Configure a MessagePack or JSON serializer. JSON supports newline-delimited and Content-Length framing. Choose an encoding.
  • Generated client proxies: Attach an interface-backed proxy instead of constructing requests manually, with positional or named arguments. Use client proxies.
  • OpenRPC discovery: Describe registered methods, parameters, results, and errors using serializer-generated JSON Schemas, locally or remotely through rpc.discover. Discover an API.
  • Batching: Send several independent requests or notifications in one JSON-RPC payload. Send a batch.
  • By-reference marshaling: Marshal interfaces, IObserver<T>, IProgress<T>, streams and pipes, and IAsyncEnumerable<T> by reference instead of by value. Marshal objects by reference.

Read the full feature overview, including method naming, events, protocol behavior, and security.

Getting started

JSON-RPC is a peer-to-peer protocol. Either party may expose methods, invoke methods exposed by the other party, or do both over the same connection.

Get started by defining a shared contract, opening a connection, and calling it through a generated proxy.