Created
July 15, 2017 16:19
-
-
Save gavi/eeedaa6b51fd094cd7150812683145cf to your computer and use it in GitHub Desktop.
JSON Decoding in Swift Basic
This file contains hidden or 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 inputData = """ | |
{"x":10,"y":10,"moment":"2017-06-08T21:36:37Z"} | |
""".data(using: .utf8)! | |
let decoder = JSONDecoder() | |
decoder.dateDecodingStrategy = .iso8601 | |
let obj=try? decoder.decode(Point.self, from: inputData) | |
if let point=obj{ | |
print(point.x) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment