Where is IRabbitMqBusFactoryConfigurator.ConfigureJsonSerializer in version 8.0.3 in Masstransit RabbitMQ?

Viewed 115

We upgraded from Masstransit 7.0.6 to 8.0.3

Previously we were configuring ConfigureJsonSerializer. But this seems removed from version 8.0.3. Source code below

x.UsingRabbitMq((context, cfg) =>
{
    cfg.Host(Config.GetValue<string>("RabbitMQ:Host"), "/", h =>
    {
        h.Username(Config.GetValue<string>("RabbitMQ:Username"));
        h.Password(Config.GetValue<string>("RabbitMQ:Password"));
    });

    cfg.ConfigureEndpoints(context);

    cfg.ConfigureJsonSerializer(settings => { settings.DefaultValueHandling = DefaultValueHandling.Include; return settings; });
});

enter image description here

How do we replace ConfigureJsonSerializer and DefaultValueHandling ?

I see there is

cfg.UseJsonSerializer();
cfg.ConfigureJsonSerializerOptions(options => options.DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.???);

would this be the correct replacement and which DefaultIgnoreCondition ?

1 Answers

If you follow the upgrade guide, you can see that Newtonsoft is no longer the default JSON serializer. The method you pointed out above was renamed to ConfigureNewtonsoftJsonSerializer and is only in the separate Newtonsoft assembly.

If you want to configure System.Text.Json to include default values, you can configure those options using:

cfg.ConfigureJsonSerializerOptions(options => 
{
    options.DefaultIgnoreCondition = JsonIgnoreCondition.Never;
    return options;
}
Related