Table of Contents

MoneyBagJsonConverter Class

Definition

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

Converts a MoneyBag to and from JSON using the policy supplied at construction.

public sealed class MoneyBagJsonConverter : JsonConverter<MoneyBag>
Inheritance
MoneyBagJsonConverter
Inherited Members
Extension Methods

Remarks

Strict and Lenient use the canonical wrapper form { "balances": { "AUD": 12.34, "USD": 56.78 } }. Compact drops the wrapper and emits a flat ISO-code-to-amount map ({ "AUD": 12.34, "USD": 56.78 }); this is the natural minimal shape when the consumer already knows the payload is a bag.

Constructors

MoneyBagJsonConverter()

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

public MoneyBagJsonConverter()

MoneyBagJsonConverter(FinancialJsonPolicy)

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

public MoneyBagJsonConverter(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 MoneyBag.

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

MoneyBag

The converted value.

Write(Utf8JsonWriter, MoneyBag, JsonSerializerOptions)

Writes a specified value as JSON.

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

Parameters

writer Utf8JsonWriter

The writer to write to.

value MoneyBag

The value to convert to JSON.

options JsonSerializerOptions

An object that specifies serialization options to use.

Applies to

ProductVersions
.NET8, 10