Skip to content

Instantly share code, notes, and snippets.

@erickva
Last active July 12, 2016 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erickva/e509836d1f8385223cc7c85a877cb901 to your computer and use it in GitHub Desktop.
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!
//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