-
-
Notifications
You must be signed in to change notification settings - Fork 158
Support System.Text.Json #664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Right now the serialization sort of heavily relies on Newtonsoft.Json annotation internally. We could investigate what it takes to decouple this. Apart from the performance improvements, what is a usecase for using System.Text.Json rather than Newtonsoft?
Would one of the usecases be relying on just one json library instead of both ? |
To aid investigation: The limitations of and behavioral differences between System.Text.Json and Newtonsoft.Json are listed here. |
Performance comparison at https://michaelscodingspot.com/the-battle-of-c-to-json-serializers-in-net-core-3/. |
I've done a thorough investigation on the feasibility of replacing internal usage of Summary
Measurements
Observations and learnings
While working on this, several improvements came to mind:
ConclusionAside from bad error messages, the pain is mostly on our (that is, the JADNC library developers) side. We must trade a lot of declarative annotations (required, nullability, ordering etc.) for hand-written procedural code. For this investigation, I've done the minimal effort to make things work. But in addition to that, a lot of extra code is needed to validate all required elements are provided, their data types are valid, etc. in the various custom converters. But because the JSON:API structure does not change often, we should be able to manage that. This means we're going to drop support for Newtonsoft.Json in the next major version in favor of STJ, unless we receive substantial feedback to not make these changes and wait for improved support in future versions of .NET. |
With System.Text.Json gaining popularity it would be good if JsonApiDotNetCore can natively work with both it and Newtonsoft.Json. One important case is that the former is used in npgsql efcore (see http://www.npgsql.org/efcore/mapping/json.html#jsondocument-dom-mapping).
The text was updated successfully, but these errors were encountered: