Last active
April 23, 2019 15:04
-
-
Save eMdOS/88a465e8898a0600d0a343e148d6bef1 to your computer and use it in GitHub Desktop.
Codable {Apple Swift version 4.0 (swiftlang-900.0.45.6 clang-900.0.26)}
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
extension Encodable { | |
func encode(with encoder: JSONEncoder = JSONEncoder()) throws -> Data { | |
return try encoder.encode(self) | |
} | |
} | |
extension Decodable { | |
static func decode(with decoder: JSONDecoder = JSONDecoder(), from data: Data) throws -> Self { | |
return try decoder.decode(Self.self, from: data) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wow!It's beautiful and simple code! Please accept my kness!