JsonSerializerOptions 类
定义
提供与 JsonSerializer 一起使用的选项。Provides options to be used with JsonSerializer.
public ref class JsonSerializerOptions sealed
public sealed class JsonSerializerOptions
type JsonSerializerOptions = class
Public NotInheritable Class JsonSerializerOptions
- 继承
-
JsonSerializerOptions
注解
有关详细信息,请参阅 如何序列化和反序列化 JSON。For more information, see How to serialize and deserialize JSON.
构造函数
| JsonSerializerOptions() |
初始化 JsonSerializerOptions 类的新实例。Initializes a new instance of the JsonSerializerOptions class. |
| JsonSerializerOptions(JsonSerializerDefaults) |
使用由指定的 JsonSerializerDefaults 确定的一组预定义选项构造新的 JsonSerializerOptions 实例。Constructs a new JsonSerializerOptions instance with a predefined set of options determined by the specified JsonSerializerDefaults. |
| JsonSerializerOptions(JsonSerializerOptions) |
将 JsonSerializerOptions 实例的选项复制到新实例。Copies the options from a JsonSerializerOptions instance to a new instance. |
属性
| AllowTrailingCommas |
获取或设置一个值,该值指示要反序列化的 JSON 有效负载中是否允许(和忽略)对象或数组中 JSON 值的列表末尾多余的逗号。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. |
| Converters |
获取已注册的用户定义的转换器的列表。Gets the list of user-defined converters that were registered. |
| DefaultBufferSize |
获取或设置创建临时缓冲区时要使用的默认缓冲区大小(以字节为单位)。Gets or sets the default buffer size, in bytes, to use when creating temporary buffers. |
| DefaultIgnoreCondition |
指定一个条件,用于确定何时在序列化或反序列化过程中忽略具有默认值的属性。Specifies a condition to determine when properties with default values are ignored during serialization or deserialization. 默认值为 Never。The default value is Never. |
| DictionaryKeyPolicy |
获取或设置用于将 IDictionary 密钥名称转换为其他格式(如 camel 大小写)的策略。Gets or sets the policy used to convert a IDictionary key's name to another format, such as camel-casing. |
| Encoder |
获取或设置要在转义字符串时使用的编码器,或为 |
| IgnoreNullValues |
获取或设置一个值,该值确定是否 |
| IgnoreReadOnlyFields |
确定序列化过程中是否忽略只读字段。Determines whether read-only fields are ignored during serialization. 如果某字段用 |
| IgnoreReadOnlyProperties |
获取一个值,该值确定序列化过程中是否忽略只读属性。Gets a value that determines whether read-only properties are ignored during serialization. 默认值为 |
| IncludeFields |
确定是否在序列化和反序列化期间处理字段。Determines whether fields are handled during serialization and deserialization.
默认值为 |
| MaxDepth |
获取或设置序列化或反序列化 JSON 时允许的最大深度,默认值 0 表示最大深度为 64。Gets or sets the maximum depth allowed when serializing or deserializing JSON, with the default value of 0 indicating a maximum depth of 64. |
| NumberHandling |
指定序列化或反序列化时应如何处理数字类型。Specifies how number types should be handled when serializing or deserializing. |
| PropertyNameCaseInsensitive |
获取或设置一个值,该值确定在反序列化过程中属性名称是否使用不区分大小写的比较。Gets or sets a value that determines whether a property's name uses a case-insensitive comparison during deserialization. 默认值为 |
| PropertyNamingPolicy |
获取或设置一个值,该值指定用于将对象的属性名称转换为其他格式(例如 camel 大小写)的策略;若为 |
| ReadCommentHandling |
获取或设置一个值,该值定义反序列化过程中如何处理注释。Gets or sets a value that defines how comments are handled during deserialization. |
| ReferenceHandler |
配置在读取和写入 JSON 时如何处理对象引用。Configures how object references are handled when reading and writing JSON. |
| WriteIndented |
获取或设置一个值,该值定义 JSON 是否应使用整齐打印。Gets or sets a value that defines whether JSON should use pretty printing. 默认情况下,不使用任何额外的空白来序列化 JSON。By default, JSON is serialized without any extra white space. |
方法
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| GetConverter(Type) |
返回指定类型的转换器。Returns the converter for the specified type. |
| GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |