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
TypeType 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
JsonReaderThe JSON reader.
objectType
TypeType of the object.
existingValue
objectThe existing instance of
T
to populate.serializer
JsonSerializerThe 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
JsonWriterThe JSON writer.
value
objectThe object value.
serializer
JsonSerializerThe JSON serializer.
Exceptions
- NotSupportedException
Always thrown because writing is not supported.