-
Notifications
You must be signed in to change notification settings - Fork 27
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
Replacing Newtonsoft with System.Text.Json #1257
Comments
Hi @rogierv, Unfortunately it will not be straightforward to replace Newtonsoft with System.Text.Json because users will have stored sagas encoded with Newtonsoft that must still be readable even if new sagas are encoded with System.Text.Json. (Though the fact that SQL Persistence stores the version along with each saga will help.) But if all you're after is serialization of polymorphic types in your saga data, Newtonsoft can already handle that. Add this to your endpoint configuration: var persistence = endpointConfiguration.UsePersistence<SqlPersistence>();
var sagaSettings = persistence.SagaSettings();
sagaSettings.JsonSettings(new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto
}); Then if the actual type of the object differs from the declared type, Newtonsoft will output a Here is the Newtonsoft documentation for the TypeNameHandling options. |
Thank you, @DavidBoike, for your explanation. It's good to know that there is an option to configure serialization at the endpoint. |
any progress on this?
an interim version that reads in Newtonsoft + System.Text.Json and writes in System.Text.Json should make this possible |
This is a good idea tbh. NServiceBus is our last dependency that still uses Newtonsoft. Would be nice to kill it all together. |
Describe the feature.
Are there plans to replace Newtonsoft with System.Text.Json in NServiceBus.Persistence.Sql? Currently, we are implementing NServiceBus 8.1, in which we can use SystemJsonSerializer. This allows us to use the handy JsonDerivedTypes attribute on base classes. It would be great to use them in Sagas as well.
Additional Context
No response
The text was updated successfully, but these errors were encountered: