Class JsonResponseNegotiator
- Namespace
- Codebelt.Extensions.Carter.AspNetCore.Text.Json
- Assembly
- Codebelt.Extensions.Carter.AspNetCore.Text.Json.dll
Provides a JSON response negotiator for Carter, capable of serializing response models to JSON format using System.Text.Json.
public class JsonResponseNegotiator : ConfigurableResponseNegotiator<JsonFormatterOptions>, IConfigurable<JsonFormatterOptions>, IResponseNegotiator
- Inheritance
-
JsonResponseNegotiator
- Implements
- Inherited Members
Constructors
JsonResponseNegotiator(IOptions<JsonFormatterOptions>)
Initializes a new instance of the JsonResponseNegotiator class.
public JsonResponseNegotiator(IOptions<JsonFormatterOptions> options)
Parameters
optionsIOptions<JsonFormatterOptions>The JsonFormatterOptions used to configure JSON serialization and supported media types.
Methods
GetDefaultEncoding()
Returns UTF-8 without a byte-order mark (BOM) as the default character encoding for this negotiator.
protected override Encoding GetDefaultEncoding()
Returns
- Encoding
A UTF8Encoding instance with the byte-order mark disabled.
GetFormatter()
Returns a new JsonFormatter configured with the current JsonFormatterOptions.
public override StreamFormatter<JsonFormatterOptions> GetFormatter()
Returns
- StreamFormatter<JsonFormatterOptions>
A JsonFormatter instance configured with the current JsonFormatterOptions.
See Also
ConfigurableResponseNegotiator<TOptions>