title: Swift store data from a Webrequest into structures
body: <p>First of all I'm really beginner in Swift. I'm stuck for hours on this.</p>
  
  <p>Here is the problem, I'm using AlamoFire in order to make my request </p>
  
  <pre><code>func getListFiles(userId: String, page: Int)
  {
      let parameters: Parameters = [
          "userId": userId,
          "page": page
      ]
  
      Alamofire.request(baseUrl + Endpoints.GET_RECORDS.rawValue, method: HTTPMethod.post, parameters: parameters)
          .responseData { response in
              if let result = response.result.value{
                  do {
                      let data = try JSONDecoder().decode(ListFilesStruct.self, from: result)
                  } catch {
                      print("\(error)")
                  }
              }
      }
  }
  </code></pre>
  
  <p>and I want to store data response in my structure "ListFilesStruct". But it enters in the "catch" and fails </p>
  
  <pre><code>Printing description of error:
  ▿ DecodingError
    ▿ typeMismatch : 2 elements
  - .0 : Swift.Dictionary&lt;Swift.String, Any&gt;
  ▿ .1 : Context
    ▿ codingPath : 3 elements
      - 0 : CodingKeys(stringValue: "data", intValue: nil)
      ▿ 1 : _JSONKey(stringValue: "Index 6", intValue: 6)
        - stringValue : "Index 6"
        ▿ intValue : Optional&lt;Int&gt;
          - some : 6
      - 2 : CodingKeys(stringValue: "expert", intValue: nil)
    - debugDescription : "Expected to decode Dictionary&lt;String, Any&gt; but found a string/data instead."
    - underlyingError : nil
  </code></pre>
  
  <p>Here is the main structure, I want an array of FileDetail</p>
  
  <pre><code>struct ListFilesStruct: Codable
  {
      var success: Bool?
      var data: [FileDetail]?
  }
  
  struct FileDetail: Codable
  {
      var id: String?
      var expert: FileElement?
  }
  </code></pre>
  
  <p>And it exactly fails because of FileElement structure , I don't know why</p>
  
  <pre><code>struct FileElement: Codable
  {
      var id: String?
      var role_id: String?
      var avatar: String?
      var nom: String?
      var prenom: String?  
  }
  </code></pre>
  
  <p>I really want to store Webservice data like that , thanks</p>
  
  <p>EDIT : Expected JSON :</p>
  
  <pre><code>{
  "success": true,
  "data": [
      {
          "id": "A19007994",
          "expert": {
              "id": "74EJEEZM",
              "role_id": "EXPERT",
              "avatar": null,
              "nom": "METRTALZ",
              "prenom": "JEREMIE",
          }
       }
   ]
   }
  </code></pre>