StringEnumConverter Class

Namespace: Stimulsoft.Base.Json.Converters

Converts an Enum to and from its name string value.

Inheritance

Inherits from: JsonConverter

Constructors

Constructor Description
StringEnumConverter() Initializes a new instance of the StringEnumConverter class.

StringEnumConverter()

Initializes a new instance of the StringEnumConverter class.

Properties

Property Type Description
AllowIntegerValues bool Gets or sets a value indicating whether integer values are allowed.
CamelCaseText bool Gets or sets a value indicating whether the written enum text should be camel case.

Methods

Method Returns Description
CanConvert bool Determines whether this instance can convert the specified object type.
ReadJson object Reads the JSON representation of the object.
WriteJson void Writes the JSON representation of the object.

Method Details

CanConvert

CanConvert(objectType: Type): bool

Determines whether this instance can convert the specified object type.

Parameters

  • objectType (Type) — Type of the object.

Returns bool — true if this instance can convert the specified object type; otherwise, false.


ReadJson

ReadJson(reader: JsonReader, objectType: Type, existingValue: object, serializer: JsonSerializer): object

Reads the JSON representation of the object.

Parameters

  • reader (JsonReader) — The JsonReader to read from.
  • objectType (Type) — Type of the object.
  • existingValue (object) — The existing value of object being read.
  • serializer (JsonSerializer) — The calling serializer.

Returns object — The object value.


WriteJson

WriteJson(writer: JsonWriter, value: object, serializer: JsonSerializer): void

Writes the JSON representation of the object.

Parameters

  • writer (JsonWriter) — The JsonWriter to write to.
  • value (object) — The value.
  • serializer (JsonSerializer) — The calling serializer.