title: Swift loop through array of dictionaries and create a new one
body: <p>I'm struggling on getting a new array of dictionaries with conditioned 10 elements out of 80.</p>
  
  <p>here is sample of students json:</p>
  
  <pre><code>{
      "id": 111,
      "name": "John",
      "gender": "male",
      "grade": 80,
      "extraCredit": 20
  },
  {
      "id": 112,
      "name": "Jenny",
      "gender": "female",
      "grade": 85,
      "extraCredit": 5
  }
  </code></pre>
  
  <p>and my struct:</p>
  
  <pre><code>struct StudentData: Decodable {
    var id: Int
    var name: String
    var grade: Int
    var extraCredit: Int
  }
  </code></pre>
  
  <p>I need to calculate each student's grade to get final grade and display top 10
  here is my code to loop through:</p>
  
  <pre><code>var newStudentData = [Dictionary&lt;String, Any&gt;]()
  for student in studentData {
    let finalGrade = student.grade + (student.extraCredit * 0.5)
    if finalGrade &gt; 88 {
       newStudentData.append(student)   // error on cannot convert value type of ’StudentData’ to expected argument type ‘[String: Any]
    }
  }
  </code></pre>
  
  <p>what did I do wrong? or is there a better way?</p>