Table of Contents

CurrencyPairJsonConverter Class

Definition

Namespace
Bodu.Financial.Serialization.Json
Assembly
Bodu.Financial.Serialization.Json.dll
Package
Bodu.Financial.Serialization.Json 1.0.0
Source
CurrencyPairJsonConverter.cs

Converts an CurrencyPair to and from JSON using the policy supplied at construction.

public sealed class CurrencyPairJsonConverter : JsonConverter<CurrencyPair>
Inheritance
CurrencyPairJsonConverter
Inherited Members
Extension Methods

Remarks

Strict and Lenient use the canonical object form { "from": "USD", "to": "JPY" }; Lenient additionally normalises lowercase ISO codes to uppercase and trims surrounding whitespace. Compact uses the slash-separated string form "USD/JPY".

Constructors

CurrencyPairJsonConverter()

Initializes a new instance of the CurrencyPairJsonConverter class configured for the Strict shape.

public CurrencyPairJsonConverter()

CurrencyPairJsonConverter(FinancialJsonPolicy)

Initializes a new instance of the CurrencyPairJsonConverter class configured for the supplied policy.

public CurrencyPairJsonConverter(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 CurrencyPair.

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

CurrencyPair

The converted value.

Write(Utf8JsonWriter, CurrencyPair, JsonSerializerOptions)

Writes a specified value as JSON.

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

Parameters

writer Utf8JsonWriter

The writer to write to.

value CurrencyPair

The value to convert to JSON.

options JsonSerializerOptions

An object that specifies serialization options to use.

Applies to

ProductVersions
.NET8, 10