Class GeotabJsonConverter2<T>
- Namespace
- Geotab.Checkmate.Serialization
- Assembly
- Geotab.Checkmate.ObjectModel.dll
An abstract class used to control the conversion of objects to JSON.
public class GeotabJsonConverter2<T> : BaseJsonConverter2<T> where T : class
Type Parameters
TThe type of this converter.
- Inheritance
-
GeotabJsonConverter2<T>
- Derived
- Inherited Members
Constructors
GeotabJsonConverter2()
public GeotabJsonConverter2()
Fields
DontSerialize
A static object used to indicate that something should not be serialized.
protected static readonly object DontSerialize
Field Value
Serialize
A static object used to indicate that something should be serialized.
protected static readonly object Serialize
Field Value
Methods
CanConvert(Type)
public override bool CanConvert(Type typeToConvert)
Parameters
typeToConvertType
Returns
GetProperties(Type)
Get properties for a type using a cache.
protected static (Dictionary<string, PropertyInfo> Dict, (string Name, PropertyInfo Info)[] Array) GetProperties(Type objectType)
Parameters
objectTypeTypeThe objectType.
Returns
- (Dictionary<string, PropertyInfo> Dict, (string Name, PropertyInfo Info)[] Array)
properties
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Read and convert the JSON to T.
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
readerUtf8JsonReaderThe Utf8JsonReader to read from.
typeToConvertTypeThe Type being converted.
optionsJsonSerializerOptionsThe JsonSerializerOptions being used.
Returns
- T
The value that was converted.
Remarks
A converter may throw any Exception, but should throw
ReadJsonCore(in JsonElement, Type, JsonSerializerOptions, HashSet<string>?)
Implementation method for read.
protected T ReadJsonCore(in JsonElement jsonElement, Type typeToConvert, JsonSerializerOptions options, HashSet<string>? keysToSkip = null)
Parameters
jsonElementJsonElementThe JsonElement.
typeToConvertTypeThe type to return.
optionsJsonSerializerOptionsThe serializer options.
keysToSkipHashSet<string>Keys which will be skipped during reading.
Returns
- T
The T.
Write(Utf8JsonWriter, T, JsonSerializerOptions)
Write the value as JSON.
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWriterThe Utf8JsonWriter to write to.
valueTThe value to convert.
optionsJsonSerializerOptionsThe JsonSerializerOptions being used.
Remarks
A converter may throw any Exception, but should throw
WriteJson(Utf8JsonWriter, T?, JsonSerializerOptions)
Same as WriteJson{JsonWriter, object, JsonSerializerOptions} but after the null check has been performed. If value is null it is OK to write.
public virtual void WriteJson(Utf8JsonWriter writer, T? value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWriterThe writer.
valueTThe value.
optionsJsonSerializerOptionsThe serializer options.
WriteObject(Utf8JsonWriter, T?, JsonSerializerOptions, Func<PropertyInfo, T, object?>?)
Creates a JSON object and writes all of value's properties to it.
protected static void WriteObject(Utf8JsonWriter writer, T? value, JsonSerializerOptions options, Func<PropertyInfo, T, object?>? getPropertyValue = null)
Parameters
writerUtf8JsonWriterThe writer.
valueTThe value.
optionsJsonSerializerOptionsThe options.
getPropertyValueFunc<PropertyInfo, T, object>Gets the value of a property with name specified as the first parameter from object in the third parameter. When overridden in a derived class properties can be excluded from serialization by returning DontSerialize.
WriteObjectProperties(Utf8JsonWriter, T, JsonSerializerOptions, Func<PropertyInfo, T, object?>?)
Writes value's properties.
protected static void WriteObjectProperties(Utf8JsonWriter writer, T value, JsonSerializerOptions options, Func<PropertyInfo, T, object?>? getPropertyValue = null)
Parameters
writerUtf8JsonWriterThe writer.
valueTThe value.
optionsJsonSerializerOptionsThe options.
getPropertyValueFunc<PropertyInfo, T, object>The get property value.
WriteSystemEntity(Utf8JsonWriter, object?)
Checks if the provided object is a System Entity. If it is it writes it and returns true, else false.
protected static bool WriteSystemEntity(Utf8JsonWriter writer, object? value)
Parameters
writerUtf8JsonWriterThe writer.
valueobjectThe value.