title: Swift 4 + Alamofire: parse array of custom struct
body: <p>My API returns the following JSON (an array of [CustomClass]):</p>
  
  <pre><code>[{
          "name": "Name A",
          "startingDate": "2018-01-01",
          "duration": 4
      },
      {
          "name": "Name B",
          "startingDate": "2018-01-01",
          "duration": 4
      }
  ]
  </code></pre>
  
  <p>I'm using Alamofire to make the request and then parsing the JSON:</p>
  
  <pre><code>static func test(parametersGet:Parameters, completion: @escaping ([CustomStruct]?, Error?) -&gt; Void ) {
          Alamofire.request(API.test, parameters: parametersGet).validate().responseJSON { response in
              switch response.result {
              case .success:
                  if let json = response.result.value {
                      let workoutCards = json as! [CustomStruct]
                      completion(workoutCards, nil)
                  }
              case .failure(let error):
                  completion(nil, error)
              }
          }
      }
  </code></pre>
  
  <p>CustomStruct it's simply a Codable struct with those keys.</p>
  
  <p>I get the following error: "Could not cast value of type '__NSDictionaryI' to 'Project.CustomStruct'". How can I parse the JSON?</p>