Skip to content

Commit

Permalink
Support encoding UInts (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdmoreira authored May 14, 2024
1 parent f446396 commit 7777cdd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/Amplitude/Utilities/CodableExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ extension KeyedEncodingContainer {
try container.encodeIfPresent(val, forKey: JSONCodingKeys(stringValue: item.key)!)
} else if let val = item.value as? Int64 {
try container.encodeIfPresent(val, forKey: JSONCodingKeys(stringValue: item.key)!)
} else if let val = item.value as? UInt {
try container.encodeIfPresent(val, forKey: JSONCodingKeys(stringValue: item.key)!)
} else if let val = item.value as? String {
try container.encodeIfPresent(val, forKey: JSONCodingKeys(stringValue: item.key)!)
} else if let val = item.value as? Double {
Expand All @@ -148,6 +150,8 @@ extension KeyedEncodingContainer {
}
if let val = safeValue as? [Int] {
try self.encodeIfPresent(val, forKey: key)
} else if let val = safeValue as? [UInt] {
try self.encodeIfPresent(val, forKey: key)
} else if let val = safeValue as? [String] {
try self.encodeIfPresent(val, forKey: key)
} else if let val = safeValue as? [Double] {
Expand Down Expand Up @@ -175,6 +179,8 @@ extension UnkeyedEncodingContainer {
for item in value {
if let val = item.value as? Int {
try container.encodeIfPresent(val, forKey: JSONCodingKeys(stringValue: item.key)!)
} else if let val = item.value as? UInt {
try container.encodeIfPresent(val, forKey: JSONCodingKeys(stringValue: item.key)!)
} else if let val = item.value as? String {
try container.encodeIfPresent(val, forKey: JSONCodingKeys(stringValue: item.key)!)
} else if let val = item.value as? Double {
Expand Down

0 comments on commit 7777cdd

Please sign in to comment.