I would like to create a static instance of JsonSerializerOptions from System.Text.Json. This instance should have a custom list of Converters. So, my inclination:
static readonly JsonSerializerOptions serializerOptions = new JsonSerializerOptions
{
// Error - Converters cannot be assigned to
Converters = new[] { new DateTimeOffsetConverter() }
};
The docs show using Add to add a Converter once the instance exists, like:
var serializeOptions = new JsonSerializerOptions();
serializeOptions.Converters.Add(new DateTimeOffsetConverter());
Any elegant ideas to do this for a static field?