Table of Contents

Class LongConverter2

Namespace
Geotab.Serialization
Assembly
Geotab.Checkmate.ObjectModel.dll

A class that contains the logic to convert an object to JSON.

public class LongConverter2 : BaseJsonConverter2<long>
Inheritance
LongConverter2
Inherited Members

Constructors

LongConverter2(bool)

Initializes a new instance of the LongConverter2 class.

public LongConverter2(bool representJsonLongAsHexString = true)

Parameters

representJsonLongAsHexString bool

The representJsonLongAsHexString.

Methods

LongToString(long)

Converts a long to a string hex representation.

public static string LongToString(long version)

Parameters

version long

The long to convert.

Returns

string

The string value.

Read(ref Utf8JsonReader, Type, JsonSerializerOptions)

Read and convert the JSON to T.

public override long 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

long

The value that was converted.

Remarks

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

StringToLong(string?)

Converts a special hex string to a long.

public static long? StringToLong(string? stringVersion)

Parameters

stringVersion string

A hex string representation of a long.

Returns

long?

The long value.

TryHexToLong(string?, out long?)

Converts a string to a long.

public static bool TryHexToLong(string? input, out long? result)

Parameters

input string

A hex string representation of a long.

result long?

When this method returns, contains the long value if the conversion succeeded, or null if the conversion failed.

Returns

bool

true if the conversion succeeded; otherwise, false.

Write(Utf8JsonWriter, long, JsonSerializerOptions)

Write the value as JSON.

public override void Write(Utf8JsonWriter writer, long value, JsonSerializerOptions options)

Parameters

writer Utf8JsonWriter

The Utf8JsonWriter to write to.

value long

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.