Class BaseJsonConverter2<T>
- Namespace
- Geotab.Serialization
- Assembly
- Geotab.Checkmate.ObjectModel.dll
A class that contains the logic to convert an object to JSON.
public class BaseJsonConverter2<T> : JsonConverter<T>
Type Parameters
T
The type of object.
- Inheritance
-
BaseJsonConverter2<T>
- Derived
- Inherited Members
Constructors
BaseJsonConverter2()
public BaseJsonConverter2()
Properties
CanRead
Gets a value indicating whether the converter can read JSON.
public bool CanRead { get; }
Property Value
CanWrite
Gets a value indicating whether the converter can write JSON.
public bool CanWrite { get; }
Property Value
Methods
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Read and convert the JSON to T.
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
reader
Utf8JsonReaderThe Utf8JsonReader to read from.
typeToConvert
TypeThe Type being converted.
options
JsonSerializerOptionsThe JsonSerializerOptions being used.
Returns
- T
The value that was converted.
Remarks
A converter may throw any Exception, but should throw
ToCamel(string)
Formats a string to be camel cased.
protected static string ToCamel(string s)
Parameters
s
stringThe string to format.
Returns
- string
A camel cased string.
Write(Utf8JsonWriter, T, JsonSerializerOptions)
Write the value as JSON.
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
Parameters
writer
Utf8JsonWriterThe Utf8JsonWriter to write to.
value
TThe value to convert.
options
JsonSerializerOptionsThe JsonSerializerOptions being used.
Remarks
A converter may throw any Exception, but should throw
WriteProperty(Utf8JsonWriter, string, object?, JsonSerializerOptions)
Creates a property with the Utf8JsonWriter respecting the DefaultIgnoreCondition.
protected static void WriteProperty(Utf8JsonWriter writer, string propertyName, object? propertyValue, JsonSerializerOptions options)
Parameters
writer
Utf8JsonWriterThe writer.
propertyName
stringName of the property.
propertyValue
objectThe property value.
options
JsonSerializerOptionsThe options.