Set the Json Serializer options in the startup.cs class while adding the couchbase dependencies

Im trying to set up Json Serializer settings in the startup.cs class for couchbase. I have no idea on how this is actually done, current code looks something like this,

private static void AddCouchbaseDependencies(IServiceCollection services, OutboundConfiguration outboundConfiguration)

            var couchbaseConfiguration = outboundConfiguration.Couchbase.FirstOrDefault(x => x.UniqueIdentifier == "TestCouchbase");
            var testCouchbaseConfig = new testCouchbaseConfig(couchbaseConfiguration );
            services.AddSingleton(testCouchbaseConfig );
            services.AddCouchbase(client =>
                client.Servers = testCouchbaseConfig .GetServersAddress().ToList();
           }).AddCouchbaseBucket<ITestBucketProvider>(bucketName, password);

this method inturn is called from configureServices method in the startup.cs

Is this using Couchbase SDK 2.x or 3.x? The approach is slightly different.

this is using couchbase client 2.7.17 and couchbase dependency injection 2.0.2

In that case:

services.AddCouchbase(client =>
    client.Serializer = typeof(YourCustomSerializer).FullName;
    client.Servers = testCouchbaseConfig .GetServersAddress().ToList();

You would probably inherit your custom serializer from DefaultSerializer, assuming you still intend to use Newtonsoft.Json and just want to tweak configuration.

HI @btburnett3,
I have created my own custom serializer and implemented as you suggested. the only thing i need to change is rather than using
client.Serializer = typeof(YourCustomSerializer).FullName;

client.Serializer = typeof(YourCustomSerializer).AssemblyQualifiedName; 

worked for me



Great, glad to hear it!