Table of Contents

Class EnumCacheListJson<T>

Namespace
PolyMod.Json
Assembly
PolyMod.dll

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

T

The enum type of the list items.

Inheritance
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

reader Utf8JsonReader

The JSON reader, at the start of the array.

typeToConvert Type

The type to read. The method does not use it.

options JsonSerializerOptions

The 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

writer Utf8JsonWriter

The JSON writer.

value List<T>

The list of enum values to write.

options JsonSerializerOptions

The serializer options. The method gives them to the item converter.