Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using custom system.text.json convertor in masstransit


I am trying to use my custom Json convertor in Masstransit But could not find any ways to add my JsonConverterFactory class.
Besides, I could not find any information In the documentation about serialization based on system.text.json
do you have any idea?
Thanks
like image 441
Mehdi FarokhTabar Avatar asked Oct 25 '25 09:10

Mehdi FarokhTabar


2 Answers

MassTransit currently (as of v7) does not use System.Text.Json, it uses Newtonsoft.Json. There are no plans underway to add support for it at this time.

If you were using JSON.net, you can add additional converters by configuring the JSON serializer.

cfg.ConfigureJsonSerializer(settings => settings.Converters.Add(...))

It's important to leave the existing converters or you may break existing functionality.

like image 179
Chris Patterson Avatar answered Oct 27 '25 23:10

Chris Patterson


As of v8, System.Text.Json is the default Json serializer.

Configuring the serializer remains the same:

x.UsingRabbitMq((ctx, cfg) =>
{
    // ...

    cfg.ConfigureJsonSerializerOptions(opts =>
    {
        opts.Converters.Add(YOUR_CUSTOM_CONVERTER);
        return opts;
    });                
});
like image 40
galdin Avatar answered Oct 27 '25 22:10

galdin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!