Add once-removed Array extension method

This commit is contained in:
kubo_takaichi 2015-05-18 17:31:57 +09:00
parent bb3ec04ed1
commit dbfc46658f

View File

@ -8,10 +8,6 @@ import Alamofire
import PromiseKit import PromiseKit
import SwiftyJSON import SwiftyJSON
extension Request {
}
extension Bool: JSONEncodable { extension Bool: JSONEncodable {
func encode() -> AnyObject { return self } func encode() -> AnyObject { return self }
} }
@ -32,6 +28,16 @@ extension String: JSONEncodable {
func encode() -> AnyObject { return self } func encode() -> AnyObject { return self }
} }
extension Array: JSONEncodable {
func encode() -> AnyObject {
if Element.self is JSONEncodable {
return self.map { ($0 as! JSONEncodable).encode() }
} else {
return self.map { ($0 as! AnyObject) }
}
}
}
extension JSON { extension JSON {
func decode() -> Bool? { func decode() -> Bool? {
return self.bool return self.bool