 
     public func decodeArray<T>(transform: JSON -> T?) -> [T]? {
         let block: ([T], AnyObject) -> [T] = { array, element in
-            switch JSON(object: element).flatMap(transform) {
+            switch transform(JSON(object: element)) {
             case .Some(let object):
                 return array + CollectionOfOne(object)
             case .None:


    public var dictionary: [String: JSON]? {
        let block: ([String: JSON], (String, AnyObject)) -> [String: JSON] = { dictionary, element in
            switch JSON(object: element.1) {
            case .Some(let JSON):
                var mutableDictionary = dictionary
                mutableDictionary[element.0] = JSON
                return mutableDictionary
            case .None:
                return dictionary
            }
        }
        return (object as? [String: AnyObject]).map({ reduce($0, [String: JSON](), block) })
    }

    public var array: [JSON]? {
        let block: ([JSON], AnyObject) -> [JSON] = { array, element in
            switch JSON(object: element) {
            case .Some(let JSON):
                return array + CollectionOfOne(JSON)
            case .None:
                return array
            }
        }
        return (object as? [AnyObject])?.reduce([JSON](), combine: block)
    }

    public var int: Int? {

public struct JSON {
    public var object: AnyObject

    public init(object: AnyObject) {
        self.object = object
    }

    public subscript(index: Int) -> JSON? {
