Keeping System.Text.Json lean
The System.Text.Json serializer has an unexpected performance penalty when used with options
Serialization with System.Text.Json
has an unexpected performance penalty when used with options, such as setting the PropertyNamingPolicy to CamelCase. For small objects, serialization is ~200x slower! To avoid this issue, store the options object in a class member and pass that member to JsonSerializer.Serialize.