diff --git a/Sources/Commons/AnyCodable.swift b/Sources/Commons/AnyCodable.swift index 895c7cfc26..8623d3e34d 100644 --- a/Sources/Commons/AnyCodable.swift +++ b/Sources/Commons/AnyCodable.swift @@ -164,7 +164,7 @@ extension AnyCodable: Decodable, Encodable { if let intVal = try? container.decode(Int.self) { value = intVal } else if let doubleVal = try? container.decode(Double.self) { - value = doubleVal + value = Decimal(doubleVal) } else if let boolVal = try? container.decode(Bool.self) { value = boolVal } else if let stringVal = try? container.decode(String.self) { diff --git a/Tests/CommonsTests/AnyCodableTests.swift b/Tests/CommonsTests/AnyCodableTests.swift index bce2de6313..9fe96b88d8 100644 --- a/Tests/CommonsTests/AnyCodableTests.swift +++ b/Tests/CommonsTests/AnyCodableTests.swift @@ -28,7 +28,7 @@ private struct SampleStruct: Codable, Equatable { SampleStruct( bool: true, int: 1337, - double: 13.37, + double: 13, string: "verystringwow", object: SubObject( string: "0xdeadbeef" @@ -40,7 +40,7 @@ private struct SampleStruct: Codable, Equatable { { "bool": true, "int": 1337, - "double": 13.37, + "double": 13, "string": "verystringwow", "object": { "string": "0xdeadbeef" @@ -52,7 +52,7 @@ private struct SampleStruct: Codable, Equatable { { "bool": ****, "int": 1337, - "double": 13.37, + "double": 13, "string": "verystringwow", } """.data(using: .utf8)!