NullMetaListConverter¶
Namespace: MQTT_Receiver_Worker
Custom JSON converter for List<TempSensorReading> that converts lists containing only null values to null.
This converter ensures that during JSON deserialization, if a meta list contains only null entries,
the entire list is set to null instead of maintaining a list of null objects.
public class NullMetaListConverter : System.Text.Json.Serialization.JsonConverter`1[[System.Collections.Generic.List`1[[MQTT_Receiver_Worker.MQTT.Models.TempSensorReading, MQTT-Receiver-Worker, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Inheritance Object → JsonConverter → JsonConverter<List<TempSensorReading>> → NullMetaListConverter
Properties¶
HandleNull¶
Property Value¶
Type¶
Property Value¶
Constructors¶
NullMetaListConverter()¶
Methods¶
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)¶
Reads and converts the JSON to a List<TempSensorReading>.
If the resulting list contains only null values, returns null instead of the list.
public List<TempSensorReading> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters¶
reader
Utf8JsonReader&
The Utf8JsonReader to read from
typeToConvert
Type
The type to convert (List<TempSensorReading>?)
options
JsonSerializerOptions
The JsonSerializerOptions to use during deserialization
Returns¶
A List<TempSensorReading> containing the deserialized values, or null if the list
was empty, null, or contained only null values
Write(Utf8JsonWriter, List<TempSensorReading>, JsonSerializerOptions)¶
Writes the List<TempSensorReading> to JSON.
Uses the default serialization behavior without any custom logic.
public void Write(Utf8JsonWriter writer, List<TempSensorReading> value, JsonSerializerOptions options)
Parameters¶
writer
Utf8JsonWriter
The Utf8JsonWriter to write to
value
List<TempSensorReading>
The List<TempSensorReading> value to serialize
options
JsonSerializerOptions
The JsonSerializerOptions to use during serialization