Hi,
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,
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;
Sure, the pattern is actually a lot cleaner and simpler since you don’t need to inherit a custom serializer type to make it work. Here is an example using System.Text.Json as the serializer. For Newtonsoft, use the DefaultSerializer instead.
services.AddCouchbase(options =>
{
Configuration.GetSection("Couchbase").Bind(options);
var jsonOptions = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
options.WithSerializer(SystemTextJsonSerializer.Create(jsonOptions));
})