For most of our applications we are used to configuring a single JsonSerializerOptions instance that is reused everywhere. For consistency we would also like to use the same configuration for Marten, but currently it is not able to provide a JsonSerializerOptions instance that is used to configure the serializer, instead it is only possible to provide a configuration function.
My suggestion would be to introduce a new SystemTextJsonSerializer constructor that accepts a JsonSerializerOptions instance that is passed as argument to the constructors for _clean, _options, _optionsDeserialize and _withTypes. This ensures that the settings configured provided by this base JsonSerializerOptions are copied to the initial versions of the 4 internal options.
I'm not entirely sure if this is the cleanest solution, but it does the job of enabling us to provide a pre-configured JsonSerializerOptions instance.
For most of our applications we are used to configuring a single
JsonSerializerOptions
instance that is reused everywhere. For consistency we would also like to use the same configuration for Marten, but currently it is not able to provide aJsonSerializerOptions
instance that is used to configure the serializer, instead it is only possible to provide a configuration function.My suggestion would be to introduce a new
SystemTextJsonSerializer
constructor that accepts aJsonSerializerOptions
instance that is passed as argument to the constructors for_clean
,_options
,_optionsDeserialize
and_withTypes
. This ensures that the settings configured provided by this baseJsonSerializerOptions
are copied to the initial versions of the 4 internal options.I'm not entirely sure if this is the cleanest solution, but it does the job of enabling us to provide a pre-configured
JsonSerializerOptions
instance.