Support for System.Text.Json
See original GitHub issueThe built-in JSON serializer uses Newtonsoft.Json. But in ASP.NET Core 3.0, the default serializer is System.Text.Json. It would be nice if Tiny.RestClient supported it, because:
- It has better performance than Newtonsoft.Json
- If the rest of the application uses System.Text.Json, it would be better if everything used it. It would be more consistent, and would allow reuse of the same settings, converters, etc.
It’s easy enough to implement a IFormatter
that uses System.Text.Json, but there’s a bit of an impedance mismatch between the IFormatter
and System.Text.Json APIs… IFormatter
only has synchronous methods that take a Stream
. But System.Text.Json doesn’t have synchronous methods that accept a stream, only async ones. And they return a ValueTask
, so we can’t just use .Result
.
Maybe the solution would be to add a IAsyncFormatter
interface. If the formatter implements it, use the async methods, if not, use the sync methods.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Migrate from Newtonsoft.Json to System.Text.Json - .NET
Supported by built-in functionality. Getting similar behavior from System.Text.Json may require the use of an attribute or global option.
Read more >System.Text.Json 7.0.3
Provides high-performance and low-allocating types that serialize objects to JavaScript Object Notation (JSON) text and deserialize JSON text to objects, ...
Read more >Introduction to System.Text.Json Through Examples
System.Text.Json library helps us handle JSON in ASP.NET applications. It comes integrated with the framework and it's simple and easy to ...
Read more >Using System.Text.Json to do polymorphic Json conversion in ...
Here are a few helpful converters - for example for doing polymorphic conversion.
Read more >Should you use Newtonsoft.Json or System.Text. ...
James Newton King works on both of them. System.text.json uses Spans under the covers and is apparently dozens of times faster, but Span...
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 FreeTop 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
Top GitHub Comments
Hello guys,
I have a PR ready which remove NewtownSoft.Json and make library compatible with System.Text.Json.
I will release this week the version 2.0 of the library
I am also writing benchmarks to try to remove unecessary allocations.
It’s already possible today, by providing your own implementation of IFormatter. Anyway, maybe Newtonsoft.Json support could be provided as a separate package.
Yes, but GRPC is not ReST…