Created
July 3, 2019 20:27
-
-
Save nishabe/910cbba5c81cc2eead3ee8b02f5a7733 to your computer and use it in GitHub Desktop.
Serialize an Object to JSON in swift
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
do { | |
let jsonData = try JSONEncoder().encode(myObjectHere) | |
let json = String(data: jsonData, encoding: .utf8) | |
print(json!) | |
} | |
catch { | |
print(error) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment