JsonStringEnumConverter 类
定义
将枚举值转换为字符串以及从字符串转换为枚举值。Converts enumeration values to and from strings.
public ref class JsonStringEnumConverter sealed : System::Text::Json::Serialization::JsonConverterFactory
public sealed class JsonStringEnumConverter : System.Text.Json.Serialization.JsonConverterFactory
type JsonStringEnumConverter = class
inherit JsonConverterFactory
Public NotInheritable Class JsonStringEnumConverter
Inherits JsonConverterFactory
- 继承
注解
读取不区分大小写。Reading is case insensitive. 可以使用自定义编写 JsonNamingPolicy 。Writing can be customized by using a JsonNamingPolicy.
有关详细信息,请参阅 如何序列化和反序列化 JSON。For more information, see How to serialize and deserialize JSON.
构造函数
JsonStringEnumConverter() |
使用允许整数值的默认命名策略初始化 JsonStringEnumConverter 类的实例。Initializes an instance of the JsonStringEnumConverter class with the default naming policy that allows integer values. |
JsonStringEnumConverter(JsonNamingPolicy, Boolean) |
使用指定命名策略以及指示是否允许未定义枚举值的值初始化 JsonStringEnumConverter 类的实例。Initializes an instance of the JsonStringEnumConverter class with a specified naming policy and a value that indicates whether undefined enumeration values are allowed. |
方法
CanConvert(Type) |
确定是否可将指定类型转换为枚举。Determines whether the specified type can be converted to an enum. |
CreateConverter(Type, JsonSerializerOptions) |
创建指定类型的转换器。Creates a converter for the specified type. |
Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
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) |