Class JsonSerializationOutputFormatter
- Namespace
- Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json
- Assembly
- Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.dll
This class handles serialization of objects to JSON using JsonFormatter.
public class JsonSerializationOutputFormatter : StreamOutputFormatter<JsonFormatter, JsonFormatterOptions>, IOutputFormatter, IApiResponseTypeMetadataProvider, IConfigurable<JsonFormatterOptions>
- Inheritance
-
JsonSerializationOutputFormatter
- Implements
- Inherited Members
- Extension Methods
Examples
The following example demonstrates how to construct a and inspect its supported media types and encodings.
using System;
using System.Linq;
using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json;
using Cuemon.Extensions.Text.Json.Formatters;
namespace DocfxExamples;
public class JsonSerializationOutputFormatterExample
{
public void Demonstrate()
{
var options = new JsonFormatterOptions();
var formatter = new JsonSerializationOutputFormatter(options);
Console.WriteLine($"Supported media types: {string.Join(", ", formatter.SupportedMediaTypes)}");
Console.WriteLine($"Supported encodings: {string.Join(", ", formatter.SupportedEncodings.Select(e => e.WebName))}");
}
}
Constructors
JsonSerializationOutputFormatter(JsonFormatterOptions)
Initializes a new instance of the JsonSerializationOutputFormatter class.
public JsonSerializationOutputFormatter(JsonFormatterOptions options)
Parameters
optionsJsonFormatterOptionsThe JsonFormatterOptions which need to be configured.