question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.Text.Json in SignalR

See original GitHub issue

System.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:closed
  • Created 4 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
BrennanConroycommented, May 7, 2019

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.

1reaction
analogrelaycommented, May 7, 2019

I believe System.Text.Json does not currently suppport an equivalent to ReferenceLoopHandling and 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 NullValueHandling you can do something similar with this code:

services.AddSignalR()
    .AddJsonProtocol(options => {
        options.PayloadSerializerOptions.IgnoreNullValues = true;
    });
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found