Table of Contents

MoneyOfTCurrencyJsonConverter<TCurrency> Class

Definition

Namespace
Bodu.Financial.Serialization.Json
Assembly
Bodu.Financial.Serialization.Json.dll
Package
Bodu.Financial.Serialization.Json 1.0.0
Source
MoneyOfTCurrencyJsonConverter{T}.cs

Converts a Money<TCurrency> to and from JSON using the policy supplied at construction.

public sealed class MoneyOfTCurrencyJsonConverter<TCurrency> : JsonConverter<Money<TCurrency>> where TCurrency : ICurrency

Type Parameters

TCurrency

The currency type identifier.

Inheritance
JsonConverter<Money<TCurrency>>
MoneyOfTCurrencyJsonConverter<TCurrency>
Inherited Members
Extension Methods

Remarks

The converter shape is selected by FinancialJsonPolicy:

Constructors

MoneyOfTCurrencyJsonConverter()

Initializes a new instance of the MoneyOfTCurrencyJsonConverter<TCurrency> class configured for the Strict shape.

public MoneyOfTCurrencyJsonConverter()

MoneyOfTCurrencyJsonConverter(FinancialJsonPolicy)

Initializes a new instance of the MoneyOfTCurrencyJsonConverter<TCurrency> class configured for the supplied policy.

public MoneyOfTCurrencyJsonConverter(FinancialJsonPolicy policy)

Parameters

policy FinancialJsonPolicy

The serialization policy.

Exceptions

ArgumentOutOfRangeException

policy is not a defined FinancialJsonPolicy value.

Methods

Read(ref Utf8JsonReader, Type, JsonSerializerOptions)

Reads and converts the JSON to type Money.

public override Money<TCurrency> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

Parameters

reader Utf8JsonReader

The reader.

typeToConvert Type

The type to convert.

options JsonSerializerOptions

An object that specifies serialization options to use.

Returns

Money<TCurrency>

The converted value.

Write(Utf8JsonWriter, Money<TCurrency>, JsonSerializerOptions)

Writes a specified value as JSON.

public override void Write(Utf8JsonWriter writer, Money<TCurrency> value, JsonSerializerOptions options)

Parameters

writer Utf8JsonWriter

The writer to write to.

value Money<TCurrency>

The value to convert to JSON.

options JsonSerializerOptions

An object that specifies serialization options to use.

Applies to

ProductVersions
.NET8, 10