Created
July 30, 2020 03:07
-
-
Save ham-burger/c7391dab67b46144ac39ea98592e6d44 to your computer and use it in GitHub Desktop.
JSON encode decode extension in swift
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 JSONDecoder{ | |
static var commonSettingInstance: JSONDecoder { | |
let decoder = JSONDecoder() | |
decoder.keyDecodingStrategy = .convertFromSnakeCase | |
decoder.dateDecodingStrategy = .iso8601 | |
return decoder | |
} | |
} |
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 JSONEncoder { | |
static var commonSettingInstance: JSONEncoder { | |
let encoder = JSONEncoder() | |
encoder.keyEncodingStrategy = .convertToSnakeCase | |
encoder.dateEncodingStrategy = .iso8601 | |
return encoder | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment