Skip to content

Instantly share code, notes, and snippets.

@eMdOS
Last active April 23, 2019 15:04
Show Gist options
  • Save eMdOS/88a465e8898a0600d0a343e148d6bef1 to your computer and use it in GitHub Desktop.
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)}
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)
}
}
@rusher-R
Copy link

Wow!It's beautiful and simple code! Please accept my kness!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment