System.Text.Json in SignalR
See original GitHub issueSystem.Text.Json is now the default Hub Protocol used by SignalR clients and servers starting in ASP.NET Core 3.0-preview5.
This is my configuration in preview4:
services.AddSignalR().AddNewtonsoftJsonProtocol(options =>
{
options.PayloadSerializerSettings.NullValueHandling = NullValueHandling.Ignore;
options.PayloadSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
});
How to migrate this in order to ignore NullValueHandling and ReferenceLoopHandling for SignalR JSON Protocol in preview5?
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
c# - SignalR switching from NewtonsoftJsonProtocol to ...
I think the point here is that to switch from Newtonsoft.Json to System.Text.Json, its not just about changing the protocol in the configuration ......
Read more >ASP.NET Core SignalR configuration
JSON /MessagePack serialization options ASP.NET Core SignalR supports two protocols for encoding messages: JSON and MessagePack. Each protocol ...
Read more >Gotcha - System.Text.Json and Dictionary<int, object>
I was personally running into a problem, migrating my application to .NET Core 3.0, I found that they updated the internal SignalR Core...
Read more >Should you use Newtonsoft.Json or System.Text. ...
Json uses Textwriters I think and strings which are represented as utf-16 internally. System.Text.Json works directly with buffers in UTF-8 ...
Read more >Microsoft.AspNetCore.SignalR.Protocols.Json 7.0.10
Version Downloads Last updated
8.0.0‑preview.7.23375.9 1,255 11 days ago
8.0.0‑preview.6.23329.11 2,299 a month ago
8.0.0‑preview.5.23302.2 2,189 2 months ago
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I am using https://github.com/dotnet/corefx/issues/36510 to track cyclic references.
You will need to add a reference to “Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson” starting in preview5 if you want to continue using Newtonsoft.Json.
I believe System.Text.Json does not currently suppport an equivalent to
ReferenceLoopHandlingand likely won’t support it in 3.0. @joshfree / @ahsonkhan do you know if there’s an issue discussing adding this functionality in the future?This is a good case where you probably want to continue using Newtonsoft.Json for now. We know that System.Text.Json will not cover all the same cases as Newtonsoft.Json (at least in the initial 3.0 release), so the Newtonsoft.Json package is going to remain in place and fully supported.
For
NullValueHandlingyou can do something similar with this code: