Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Text.​Json.​JsonSerializerOptions
Assembly: System.Text.Json
Inheritance: object → JsonSerializerOptions
Provides options to be used with <see cref="T:System.Text.Json.JsonSerializer" /> .
Properties
public
bool
AllowDuplicateProperties
Gets or sets a value that indicates whether duplicate property names are allowed when deserializing JSON objects.
public
bool
AllowOutOfOrderMetadataProperties
Gets or sets a value that indicates whether JSON metadata properties can be specified after regular properties in a deserialized JSON object.
public
bool
AllowTrailingCommas
Get or sets a value that indicates whether an extra comma at the end of a list of JSON values in an object or array is allowed (and ignored) within the JSON payload being deserialized.
public
Collections.​Generic.​IList<​JsonConverter>
Converters
Gets the list of user-defined converters that were registered.
public static
JsonSerializerOptions
Default
Gets a read-only, singleton instance of <see cref="T:System.Text.Json.JsonSerializerOptions" /> that uses the default configuration.
public static
JsonSerializerOptions
Web
Gets a read-only, singleton instance of <see cref="T:System.Text.Json.JsonSerializerOptions" /> that uses the web configuration.
public
int
DefaultBufferSize
Gets or sets the default buffer size, in bytes, to use when creating temporary buffers.
public
JsonIgnoreCondition
DefaultIgnoreCondition
Gets or sets a value that determines when properties with default values are ignored during serialization or deserialization.
The default value is <see cref="F:System.Text.Json.Serialization.JsonIgnoreCondition.Never" /> .
public
JsonNamingPolicy
DictionaryKeyPolicy
Gets or sets the policy used to convert a <see cref="T:System.Collections.IDictionary" /> key's name to another format, such as camel-casing.
Gets or sets the encoder to use when escaping strings, or <see langword="null" /> to use the default encoder.
public
bool
IgnoreNullValues
Gets or sets a value that indicates whether <see langword="null" /> values are ignored during serialization and deserialization. The default value is <see langword="false" /> .
public
bool
IgnoreReadOnlyFields
Gets or sets a value that indicates whether read-only fields are ignored during serialization. A field is read-only if it is marked with the <see langword="readonly" /> keyword. The default value is <see langword="false" /> .
public
bool
IgnoreReadOnlyProperties
Gets or sets a value that indicates whether read-only properties are ignored during serialization. The default value is <see langword="false" /> .
public
bool
IncludeFields
Gets or sets a value that indicates whether fields are handled during serialization and deserialization.
The default value is <see langword="false" /> .
public
bool
IsReadOnly
Gets a value that indicates whether the current instance has been locked for user modification.
public
int
MaxDepth
Gets or sets the maximum depth allowed when serializing or deserializing JSON, with the default value of 0 indicating a maximum depth of 64.
public
string
NewLine
<para>Gets or sets the new line string to use when <see cref="P:System.Text.Json.JsonSerializerOptions.WriteIndented" /> is <see langword="true" />.</para> <para>The default is the value of <see cref="P:System.Environment.NewLine" />.</para>
public
JsonNumberHandling
NumberHandling
Gets or sets an object that specifies how number types should be handled when serializing or deserializing.
public
JsonObjectCreationHandling
PreferredObjectCreationHandling
Gets or sets the preferred object creation handling for properties when deserializing JSON.
public
bool
PropertyNameCaseInsensitive
Gets or sets a value that indicates whether a property's name uses a case-insensitive comparison during deserialization. The default value is <see langword="false" /> .
public
JsonNamingPolicy
PropertyNamingPolicy
Gets or sets a value that specifies the policy used to convert a property's name on an object to another format, such as camel-casing, or <see langword="null" /> to leave property names unchanged.
public
JsonCommentHandling
ReadCommentHandling
Gets or sets a value that defines how comments are handled during deserialization.
public
ReferenceHandler
ReferenceHandler
Gets or sets an object that specifies how object references are handled when reading and writing JSON.
public
bool
RespectNullableAnnotations
Gets or sets a value that indicates whether nullability annotations should be respected during serialization and deserialization.
public
bool
RespectRequiredConstructorParameters
Gets or sets a value that indicates whether non-optional constructor parameters should be specified during deserialization.
public static
JsonSerializerOptions
Strict
Gets a read-only, singleton instance of <see cref="T:System.Text.Json.JsonSerializerOptions" /> that uses the strict configuration.
public
IJsonTypeInfoResolver
TypeInfoResolver
Gets or sets the <see cref="T:System.Text.Json.Serialization.Metadata.JsonTypeInfo" /> contract resolver used by this instance.
public
Collections.​Generic.​IList<​IJsonTypeInfoResolver>
TypeInfoResolverChain
Gets the list of chained <see cref="T:System.Text.Json.Serialization.Metadata.JsonTypeInfo" /> contract resolvers used by this instance.
public
JsonUnknownTypeHandling
UnknownTypeHandling
Gets or sets an object that specifies how deserializing a type declared as an <see cref="T:System.Object" /> is handled during deserialization.
public
JsonUnmappedMemberHandling
UnmappedMemberHandling
Gets or sets an object that specifies how <see cref="T:System.Text.Json.JsonSerializer" /> handles JSON properties that cannot be mapped to a specific .NET member when deserializing object types.
public
bool
WriteIndented
Gets or sets a value that indicates whether JSON should use pretty printing. By default, JSON is serialized without any extra white space.
public
char
IndentCharacter
Defines the indentation character being used when <see cref="P:System.Text.Json.JsonSerializerOptions.WriteIndented" /> is enabled. Defaults to the space character.
public
int
IndentSize
Defines the indentation size being used when <see cref="P:System.Text.Json.JsonSerializerOptions.WriteIndented" /> is enabled. Defaults to two.
Methods
public
void
AddContext​()
Appends a new <see cref="T:System.Text.Json.Serialization.JsonSerializerContext" /> to the metadata resolution of the current <see cref="T:System.Text.Json.JsonSerializerOptions" /> instance.
public
JsonConverter
GetConverter​(Type typeToConvert)
Returns the converter for the specified type.
Returns The first converter that supports the given type.
typeToConvert
The type to return a converter for.
public
JsonTypeInfo
GetTypeInfo​(Type type)
Gets the <see cref="T:System.Text.Json.Serialization.Metadata.JsonTypeInfo" /> contract metadata resolved by the current <see cref="T:System.Text.Json.JsonSerializerOptions" /> instance.
Returns The contract metadata resolved for <paramref name="type" /> .
type
The type to resolve contract metadata for.
public
void
MakeReadOnly​()
Marks the current instance as read-only to prevent any further user modification.
public
void
MakeReadOnly​(bool populateMissingResolver)
Marks the current instance as read-only preventing any further user modification.
populateMissingResolver
Populates unconfigured <see cref="P:System.Text.Json.JsonSerializerOptions.TypeInfoResolver" /> properties with the reflection-based default.
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object