MoneyBagJsonConverter Class
Definition
- 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
policyFinancialJsonPolicyThe serialization policy.
Exceptions
- ArgumentOutOfRangeException
policyis 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
readerUtf8JsonReaderThe reader.
typeToConvertTypeThe type to convert.
optionsJsonSerializerOptionsAn 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
writerUtf8JsonWriterThe writer to write to.
valueMoneyBagThe value to convert to JSON.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |