JsonOutputFormatter Class

A Microsoft.AspNetCore.Mvc.Formatters.TextOutputFormatter for JSON content.

Namespace
Microsoft.AspNetCore.Mvc.Formatters
Assemblies
  • Microsoft.AspNetCore.Mvc.Formatters.Json

Syntax

public class JsonOutputFormatter : TextOutputFormatter, IOutputFormatter, IApiResponseTypeMetadataProvider
class Microsoft.AspNetCore.Mvc.Formatters.JsonOutputFormatter

Constructors

JsonOutputFormatter(Newtonsoft.Json.JsonSerializerSettings, System.Buffers.ArrayPool<System.Char>)

Initializes a new Microsoft.AspNetCore.Mvc.Formatters.JsonOutputFormatter instance.

Arguments:
public JsonOutputFormatter(JsonSerializerSettings serializerSettings, ArrayPool<char> charPool)

Methods

CreateJsonSerializer()

Called during serialization to create the Newtonsoft.Json.JsonSerializer.

Return type:Newtonsoft.Json.JsonSerializer
Returns:The Newtonsoft.Json.JsonSerializer used during serialization and deserialization.
protected virtual JsonSerializer CreateJsonSerializer()
CreateJsonWriter(System.IO.TextWriter)

Called during serialization to create the Newtonsoft.Json.JsonWriter.

Arguments:writer (System.IO.TextWriter) – The System.IO.TextWriter used to write.
Return type:Newtonsoft.Json.JsonWriter
Returns:The Newtonsoft.Json.JsonWriter used during serialization.
protected virtual JsonWriter CreateJsonWriter(TextWriter writer)
WriteObject(System.IO.TextWriter, System.Object)

Writes the given <em>value</em> as JSON using the given <em>writer</em>.

Arguments:
  • writer (System.IO.TextWriter) – The System.IO.TextWriter used to write the <em>value</em>
  • value (System.Object) – The value to write as JSON.
public void WriteObject(TextWriter writer, object value)
WriteResponseBodyAsync(Microsoft.AspNetCore.Mvc.Formatters.OutputFormatterWriteContext, System.Text.Encoding)
Return type:System.Threading.Tasks.Task
public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)

Properties

Microsoft.AspNetCore.Mvc.Formatters.JsonOutputFormatter.SerializerSettings

Gets the Newtonsoft.Json.JsonSerializerSettings used to configure the Newtonsoft.Json.JsonSerializer.

Return type:Newtonsoft.Json.JsonSerializerSettings
protected JsonSerializerSettings SerializerSettings { get; }