Table of Contents

Class JArrayToObjectConverter<T>

Namespace
Ecng.Serialization
Assembly
Ecng.Serialization.dll

Converts a JSON array to an object of type T by mapping array elements to the object's fields in declaration order using compiled IL for performance.

public class JArrayToObjectConverter<T> : JsonConverter where T : new()

Type Parameters

T

The type of the object to convert to. Must have a parameterless constructor.

Inheritance
JArrayToObjectConverter<T>
Extension Methods

Constructors

JArrayToObjectConverter()

public JArrayToObjectConverter()

Properties

CanWrite

Gets a value indicating whether this converter can write JSON.

public override bool CanWrite { get; }

Property Value

bool

Always false because writing is not supported.

Methods

CanConvert(Type)

Determines whether this converter can convert the specified object type.

public override bool CanConvert(Type objectType)

Parameters

objectType Type

Type of the object.

Returns

bool

Always returns true.

ReadJson(JsonReader, Type, object, JsonSerializer)

Reads the JSON representation of the object and maps JSON array elements to the corresponding fields of an instance of T.

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

Parameters

reader JsonReader

The JSON reader.

objectType Type

Type of the object.

existingValue object

The existing instance of T to populate.

serializer JsonSerializer

The JSON serializer.

Returns

object

The deserialized object of type T.

WriteJson(JsonWriter, object, JsonSerializer)

Not supported. Throws a NotSupportedException.

public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)

Parameters

writer JsonWriter

The JSON writer.

value object

The object value.

serializer JsonSerializer

The JSON serializer.

Exceptions

NotSupportedException

Always thrown because writing is not supported.