Created
March 26, 2019 23:08
-
-
Save dkw5877/0e249aa87a62a00fa05056dc62bd07df to your computer and use it in GitHub Desktop.
Base 64 Key Encoding and Decoding 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
let dates = ["key_1":Date()] | |
let encoder = JSONEncoder() | |
encoder.dataEncodingStrategy = .base64 | |
encoder.outputFormatting = [.sortedKeys, .prettyPrinted] | |
let encoded = try? encoder.encode(object) | |
print(String(data: encoded!, encoding: .utf8)!) | |
//output | |
{ | |
"key_1" : 574821298.18860102 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment