-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
36 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,62 +12,42 @@ import Foundation | |
import AnyCodable | ||
#endif | ||
|
||
// MARK: - Bool + JSONEncodable | ||
|
||
extension Bool: JSONEncodable { | ||
public func encodeToJSON() -> Any { self } | ||
} | ||
|
||
// MARK: - Float + JSONEncodable | ||
|
||
extension Float: JSONEncodable { | ||
public func encodeToJSON() -> Any { self } | ||
} | ||
|
||
// MARK: - Int + JSONEncodable | ||
|
||
extension Int: JSONEncodable { | ||
public func encodeToJSON() -> Any { self } | ||
} | ||
|
||
// MARK: - Int32 + JSONEncodable | ||
|
||
extension Int32: JSONEncodable { | ||
public func encodeToJSON() -> Any { self } | ||
} | ||
|
||
// MARK: - Int64 + JSONEncodable | ||
|
||
extension Int64: JSONEncodable { | ||
public func encodeToJSON() -> Any { self } | ||
} | ||
|
||
// MARK: - Double + JSONEncodable | ||
|
||
extension Double: JSONEncodable { | ||
public func encodeToJSON() -> Any { self } | ||
} | ||
|
||
// MARK: - Decimal + JSONEncodable | ||
|
||
extension Decimal: JSONEncodable { | ||
public func encodeToJSON() -> Any { self } | ||
} | ||
|
||
// MARK: - String + JSONEncodable | ||
|
||
extension String: JSONEncodable { | ||
public func encodeToJSON() -> Any { self } | ||
} | ||
|
||
// MARK: - URL + JSONEncodable | ||
|
||
extension URL: JSONEncodable { | ||
public func encodeToJSON() -> Any { self } | ||
} | ||
|
||
// MARK: - UUID + JSONEncodable | ||
|
||
extension UUID: JSONEncodable { | ||
public func encodeToJSON() -> Any { self } | ||
} | ||
|
@@ -84,24 +64,18 @@ private func encodeIfPossible(_ object: some Any) -> Any { | |
} | ||
} | ||
|
||
// MARK: - Array + JSONEncodable | ||
|
||
extension Array: JSONEncodable { | ||
public func encodeToJSON() -> Any { | ||
map(encodeIfPossible) | ||
} | ||
} | ||
|
||
// MARK: - Set + JSONEncodable | ||
|
||
extension Set: JSONEncodable { | ||
public func encodeToJSON() -> Any { | ||
Array(self).encodeToJSON() | ||
} | ||
} | ||
|
||
// MARK: - Dictionary + JSONEncodable | ||
|
||
extension Dictionary: JSONEncodable where Key == String { | ||
public func encodeToJSON() -> Any { | ||
var dictionary = [String: Any]() | ||
|
@@ -112,8 +86,6 @@ extension Dictionary: JSONEncodable where Key == String { | |
} | ||
} | ||
|
||
// MARK: - Data + JSONEncodable | ||
|
||
extension Data: JSONEncodable { | ||
public func encodeToJSON() -> Any { | ||
guard let selfString = String(data: self, encoding: .utf8) else { | ||
|
@@ -130,8 +102,6 @@ extension Data: JSONEncodable { | |
} | ||
} | ||
|
||
// MARK: - Date + JSONEncodable | ||
|
||
extension Date: JSONEncodable { | ||
public func encodeToJSON() -> Any { | ||
CodableHelper.dateFormatter.string(from: self) | ||
|
@@ -153,8 +123,6 @@ public extension JSONEncodable where Self: Encodable { | |
} | ||
} | ||
|
||
// MARK: - String + CodingKey | ||
|
||
extension String: CodingKey { | ||
public var stringValue: String { | ||
self | ||
|
@@ -284,8 +252,6 @@ extension HTTPURLResponse { | |
} | ||
} | ||
|
||
// MARK: - URLRequest.FormatError | ||
|
||
public extension URLRequest { | ||
enum FormatError: LocalizedError { | ||
case missingURL | ||
|
@@ -294,8 +260,6 @@ public extension URLRequest { | |
case invalidPath(String) | ||
case invalidQueryItems | ||
|
||
// MARK: Public | ||
|
||
public var errorDescription: String? { | ||
let contactUs = "Please contact [email protected] if this problem occurs." | ||
switch self { | ||
|
Oops, something went wrong.