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.JsonOutputFormatterinstance.Arguments: - serializerSettings (Newtonsoft.Json.JsonSerializerSettings) – The
Newtonsoft.Json.JsonSerializerSettings. Should be either the application-wide settings (Microsoft.AspNetCore.Mvc.MvcJsonOptions.SerializerSettings) or an instanceMicrosoft.AspNetCore.Mvc.Formatters.JsonSerializerSettingsProvider.CreateSerializerSettingsinitially returned. - charPool (System.Buffers.ArrayPool<System.Char>) – The
System.Buffers.ArrayPool`1.
public JsonOutputFormatter(JsonSerializerSettings serializerSettings, ArrayPool<char> charPool)
- serializerSettings (Newtonsoft.Json.JsonSerializerSettings) – The
-
Methods¶
-
CreateJsonSerializer()¶ Called during serialization to create the
Newtonsoft.Json.JsonSerializer.Return type: Newtonsoft.Json.JsonSerializer Returns: The Newtonsoft.Json.JsonSerializerused 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.TextWriterused to write.Return type: Newtonsoft.Json.JsonWriter Returns: The Newtonsoft.Json.JsonWriterused 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.TextWriterused to write the <em>value</em> - value (System.Object) – The value to write as JSON.
public void WriteObject(TextWriter writer, object value)
- writer (System.IO.TextWriter) – The
-
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.JsonSerializerSettingsused to configure theNewtonsoft.Json.JsonSerializer.Return type: Newtonsoft.Json.JsonSerializerSettings protected JsonSerializerSettings SerializerSettings { get; }
-