Class EnumCacheListJson<T>
The JSON converter that reads and writes a list of game enum values as their names in EnumCache.
The JSON form is an array of strings, for example ["imperius", "bardur"].
public class EnumCacheListJson<T> : JsonConverter<List<T>> where T : struct, Enum
Type Parameters
TThe enum type of the list items.
- Inheritance
-
JsonConverter<List<T>>EnumCacheListJson<T>
- Inherited Members
Methods
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Reads a JSON array of strings and gets the enum value for each string from EnumCache.
public override List<T> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
readerUtf8JsonReaderThe JSON reader, at the start of the array.
typeToConvertTypeThe type to read. The method does not use it.
optionsJsonSerializerOptionsThe serializer options. The method gives them to the item converter.
Returns
- List<T>
The list of enum values, in the same order as the array.
Exceptions
- JsonException
The JSON value is not an array.
Write(Utf8JsonWriter, List<T>, JsonSerializerOptions)
Writes a list of enum values as a JSON array of strings with their names from EnumCache.
public override void Write(Utf8JsonWriter writer, List<T> value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWriterThe JSON writer.
valueList<T>The list of enum values to write.
optionsJsonSerializerOptionsThe serializer options. The method gives them to the item converter.