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
TThe 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
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
ToCamel(string)
Formats a string to be camel cased.
protected static string ToCamel(string s)
Parameters
sstringThe 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
writerUtf8JsonWriterThe Utf8JsonWriter to write to.
valueTThe value to convert.
optionsJsonSerializerOptionsThe 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
writerUtf8JsonWriterThe writer.
propertyNamestringName of the property.
propertyValueobjectThe property value.
optionsJsonSerializerOptionsThe options.