irabbitmqbusfactoryconfigurator.configurejsonserializer在MassTransit RabbitMQ中的8.0.3中的configurejsonserializer在哪里?

发布于 2025-02-13 19:23:04 字数 1103 浏览 0 评论 0原文

我们从MassTransit 7.0.6升级到8.0.3

之前,我们正在配置configureJsonSerializer。但这似乎从8.0.3版本中删除。源代码下面

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; });
});

“在此处输入图像描述”

我们如何替换configurejsonserializerDefaultValueHandling

我看到

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

这会是正确的替换,哪个defaultignorecondition

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一生独一 2025-02-20 19:23:04

如果您跟随升级指南,您可以看到Newtonsoft不再是Newtonsoft是默认的JSON Serializer。您上面指出的方法被重命名为configurenewtonsoftjsonserializer,并且仅在单独的newtonsoft汇编中。

如果要配置system.text.json包含默认值,则可以使用以下方式配置这些选项:

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

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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文