Skip to content

Commit

Permalink
Double encoding bug workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
flypaper0 committed Oct 4, 2023
1 parent 77121b1 commit dbbcd39
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Sources/Commons/AnyCodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions Tests/CommonsTests/AnyCodableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -40,7 +40,7 @@ private struct SampleStruct: Codable, Equatable {
{
"bool": true,
"int": 1337,
"double": 13.37,
"double": 13,
"string": "verystringwow",
"object": {
"string": "0xdeadbeef"
Expand All @@ -52,7 +52,7 @@ private struct SampleStruct: Codable, Equatable {
{
"bool": ****,
"int": 1337,
"double": 13.37,
"double": 13,
"string": "verystringwow",
}
""".data(using: .utf8)!
Expand Down

0 comments on commit dbbcd39

Please sign in to comment.