Last active
July 12, 2016 00:43
-
-
Save erickva/e509836d1f8385223cc7c85a877cb901 to your computer and use it in GitHub Desktop.
This is a recursive function that transforms any JSON object into a Dictionary, ready to be saved into Firebase: Simple magic!
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
//JSON is created using the awesome SwiftyJSON pod | |
func json2dic(j: JSON) -> [String:AnyObject] { | |
var post = [String:AnyObject]() | |
for (key, object) in j { | |
post[key] = object.stringValue | |
if object.stringValue == "" { | |
post[key] = json2dic(object) | |
} | |
} | |
return post | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment