TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Aug 2016 |
SPMSupports SPM | ✗ |
Maintained by Max Sokolov.
Depends on: | |
Alamofire | ~> 3.2 |
Unbox | ~> 1.5 |
An extension to Alamofire which converts json response data into swift objects using Unbox.
An example app is included demonstrating functionality.
Let’s say we have a json of github users which are represented as Unboxable model:
struct User: Unboxable {
let login: String
init(unboxer: Unboxer) {
login = unboxer.unbox("login")
}
}
You could easily download an array of users using Alamofire and map them to your Unboxable models:
Alamofire
.request(.GET, "https://api.github.com/users", parameters: nil, encoding: .JSON, headers: nil)
.responseUnboxArray { (response: Response<[User], AlamofireUnboxError>) in
// response.result.value
}
Similar for regular objects:
Alamofire
.request(.GET, "https://api.github.com/users/maxsokolov", parameters: nil, encoding: .JSON, headers: nil)
.responseUnboxObject { (response: Response<User, AlamofireUnboxError>) in
// response.result.value
}
Clone the repo and drag files from Sources
folder into your Xcode project.
MIT license. See LICENSE for details.