Table of Contents

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

bool

A bool value indicating whether the converter can read JSON.

CanWrite

Gets a value indicating whether the converter can write JSON.

public bool CanWrite { get; }

Property Value

bool

A bool value indicating whether the converter can write JSON.

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 Utf8JsonReader

The Utf8JsonReader to read from.

typeToConvert Type

The Type being converted.

options JsonSerializerOptions

The JsonSerializerOptions being used.

Returns

T

The value that was converted.

Remarks

A converter may throw any Exception, but should throw JsonException when the JSON is invalid.

ToCamel(string)

Formats a string to be camel cased.

protected static string ToCamel(string s)

Parameters

s string

The 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 Utf8JsonWriter

The Utf8JsonWriter to write to.

value T

The value to convert.

options JsonSerializerOptions

The JsonSerializerOptions being used.

Remarks

A converter may throw any Exception, but should throw JsonException when the JSON cannot be created.

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 Utf8JsonWriter

The writer.

propertyName string

Name of the property.

propertyValue object

The property value.

options JsonSerializerOptions

The options.