Created
March 11, 2018 07:12
-
-
Save mukulm24/e4920c37b86b87af7b95a25f6e4e93f8 to your computer and use it in GitHub Desktop.
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
/** | |
Converts a JSON String to it's corresponding object | |
params : aptJSON -> The JSON string which needs to be decoded | |
returns: Apartment object keeping JSON string as Datasource | |
*/ | |
func decodingJSONToApartment(aptJSON : String) -> Apartment?{ | |
print("\n\nDECODING DATA") | |
if let aptJsonData = aptJSON.data(using: .utf8) { | |
let decoder = JSONDecoder() | |
if let oxfordApt = try? decoder.decode(Apartment.self, from: aptJsonData) { | |
print(oxfordApt) | |
return oxfordApt | |
} | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment