AustinHarris.JsonRpc.Newtonsoft 2.0.1

dotnet add package AustinHarris.JsonRpc.Newtonsoft --version 2.0.1
                    
NuGet\Install-Package AustinHarris.JsonRpc.Newtonsoft -Version 2.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AustinHarris.JsonRpc.Newtonsoft" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AustinHarris.JsonRpc.Newtonsoft" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="AustinHarris.JsonRpc.Newtonsoft" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AustinHarris.JsonRpc.Newtonsoft --version 2.0.1
                    
#r "nuget: AustinHarris.JsonRpc.Newtonsoft, 2.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AustinHarris.JsonRpc.Newtonsoft@2.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AustinHarris.JsonRpc.Newtonsoft&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=AustinHarris.JsonRpc.Newtonsoft&version=2.0.1
                    
Install as a Cake Tool

AustinHarris.JsonRpc.Newtonsoft

AustinHarris.JsonRpc.Newtonsoft adds Json.NET serialization to AustinHarris.JsonRpc 2.0. Choose it when your models rely on Json.NET converters, contract resolvers or [JsonProperty], or when clients send non-strict JSON.

Configure parameter and result conversion with JsonSerializerSettings.

Install

dotnet add package AustinHarris.JsonRpc.Newtonsoft

Targets netstandard2.0, netstandard2.1, net8.0 and net10.0; depends on Newtonsoft.Json 13.0.4 and the AustinHarris.JsonRpc core package.

Choosing the serializer

Process-wide (every session that does not override it):

using AustinHarris.JsonRpc;
using AustinHarris.JsonRpc.Newtonsoft;
using Newtonsoft.Json;

var settings = new JsonSerializerSettings { DateFormatString = "yyyy-MM-dd" };   // optional
Config.SetSerializer(new NewtonsoftJsonRpcSerializer(settings));

Per session:

Config.SetSerializer("session-42", new NewtonsoftJsonRpcSerializer(settings));

Per call (overrides both):

var serializer = new NewtonsoftJsonRpcSerializer(settings);
string response = JsonRpcProcessor.ProcessSync(sessionId, json, context, serializer);

When each level is the right one is covered in docs/serializers.md.

Create the serializer once and reuse it: it holds one JsonSerializer built from the settings, and the processor's synchronous path keeps an envelope reader in per-thread scratch storage for as long as the serializer instance stays the same, so a new serializer per call throws that reuse away. That JsonSerializer, its converters, contract resolver and callbacks are used concurrently by unrelated requests: configure the instance before serving traffic, do not mutate it while requests are in flight, and make custom components thread-safe.

Settings-based helpers (1.x compatibility)

The JsonSerializerSettings overloads that JsonRpcProcessor had in 1.x live here now:

string response = NewtonsoftJsonRpc.ProcessSync(sessionId, json, context, settings);
Task<string> task  = NewtonsoftJsonRpc.Process(sessionId, json, context, settings);
NewtonsoftJsonRpc.Process(sessionId, stateAsync, context, settings);

Each distinct settings instance is turned into a serializer the first time it is seen and reused afterwards (NewtonsoftJsonRpc.SerializerFor(settings) gives you that instance). null settings means Json.NET defaults.

What you get

  • Every conversion honours the settings: params, results, error.data, and the JsonRequest.Params handed to pre/post-process handlers (a JObject / JArray / primitive, as JsonConvert.DeserializeObject returns).
  • Json.NET's defaults already match the library's wire conventions: compact output, 3.0 for whole floating values, ISO-8601 dates (fraction only when non-zero, trailing zeros trimmed; Z for UTC, the offset for Local, nothing for Unspecified), char as a one-character string, nulls written, members in declaration order, case-insensitive member names on input, numbers coerced to bool/char/floating types.
  • Leniency. Json.NET accepts more than RFC 8259, and with this serializer selected so does the envelope reader: single-quoted strings, unquoted member names and trailing commas are accepted in the request, e.g. {method:'add',params:[1,2],id:1}. With the built-in serializer the same request is a -32700 parse error. Leniency applies to the HTTP endpoint and to in-process calls; on a raw Kestrel connection the framer that splits the stream into documents accepts strict JSON only.
  • JsonConvert.DefaultSettings, if your process sets it, is the baseline exactly as it is for JsonConvert.

A value Json.NET cannot convert to the parameter's type (a JsonException, or a format, overflow or cast exception while reading an argument) is reported as -32602 Invalid params, with data naming the parameter and the expected type; the value sent is never echoed. A type the serializer cannot handle at all, or an exception inside your method, is -32603 Internal error.

Performance notes

Reading decodes the value's UTF-8 bytes once into a pooled char[] and hands that to a JsonTextReader whose own buffer is rented from ArrayPool<char>; no string or MemoryStream is created. Writing keeps one JsonTextWriter per thread over a TextWriter that UTF-8 encodes straight into the caller's IBufferWriter<byte> (a PipeWriter, the HTTP body writer, or the processor's pooled buffer), so the JSON is never assembled as a string first.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.1 86 9/28/2026
2.0.0 83 9/28/2026
2.0.0-preview.3 53 9/28/2026
2.0.0-preview.2 50 9/28/2026
2.0.0-preview.1 60 9/25/2026

2.0.1, released with the core package. What is new: https://astn.github.io/JSON-RPC.NET/changelog.html. Upgrading from 1.x: https://astn.github.io/JSON-RPC.NET/upgrading.html