FinancialJsonPolicy Enum
Definition
- Assembly
- Bodu.Financial.Serialization.Json.dll
- Package
- Bodu.Financial.Serialization.Json 1.0.0
- Source
- FinancialJsonPolicy.cs
Selects the JSON serialization shape and parsing strictness applied by the Bodu.Financial JSON converters.
public enum FinancialJsonPolicy
- Extension Methods
Fields
Strict = 0Canonical JSON shape suitable for ledger, persistence, and audit data: monetary values serialize as objects with
"amount"and"currency"properties; MoneyBag serializes as an object containing a"balances"map. Property names compare case-insensitively, duplicate properties are rejected, unknown properties are ignored, and a currency code that does not matchTCurrency.IsoCodeis rejected.Lenient = 1Same on-the-wire shape as Strict, but additionally normalizes lowercase ISO currency codes to uppercase and trims surrounding whitespace before validation. Intended for import workflows that ingest data from external feeds and spreadsheets. Not suitable as a canonical storage shape.
Compact = 2Compact JSON shape: Money<TCurrency> and Money serialize as a single JSON string of the form
"<amount> <ISO>"(for example"19.99 USD"); MoneyBag serializes as a flat object mapping ISO codes to amounts (for example{ "USD": 19.99, "EUR": 12.34 }). Reads accept either ISO-prefix or ISO-suffix string forms and reuse the type'sTryParsepath for the numeric component.
Remarks
The policy is supplied either by constructing a converter directly (e.g.
new MoneyOfTCurrencyJsonConverter<USD>(FinancialJsonPolicy.Compact)) or, more commonly, through
AddFinancialJsonConverters(JsonSerializerOptions, FinancialJsonPolicy) which registers a coherent set of
converters on a JsonSerializerOptions.
The core Bodu.Financial types carry no [JsonConverter] attribute - the library is
serialization-agnostic - so registration through
AddFinancialJsonConverters(JsonSerializerOptions, FinancialJsonPolicy) is required; converters
constructed without an explicit policy default to Strict.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |