Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

MoneyDecodingOptions

mattt edited this page May 6, 2020 · 5 revisions

MoneyDecodingOptions

Custom decoding options for Money values.

public struct MoneyDecodingOptions: OptionSet

Configure the decoding behavior either by using the JSONDecoder.moneyDecodingOptions property or by setting the CodingUserInfoKey.moneyDecodingOptions key in the decoder's userInfo property.

Inheritance

OptionSet

Initializers

init(rawValue:)

public init(rawValue: Int)

Properties

rawValue

let rawValue: Int

allowSingleValues

Allows Money values to be decoded from string and number values, in addition to keyed containers, using the associated Currency type.

let allowSingleValues

requireStringAmounts

Throws an error when attempting to decode amount from a floating-point number.

let requireStringAmounts

Important: Foundation decoders currently decode number values using binary floating-point number type, which cannot precisely express certain values. Monetary amounts can, however, be precisely decoded from string values.

Bug: See https://bugs.swift.org/browse/SR-7054.

roundFloatingPointAmounts

Rounds amount to the number of places of the minor currency unit when decoding from a floating-point number.

let roundFloatingPointAmounts
Clone this wiki locally