title: Loop through custom object's properties
body: <p>I have a JSON response with a structure like this:</p>
  
  <pre><code>{
      "id": {
          "sub_key1": "sub_value1",
          "sub_key2": "sub_value2",
          "sub_key3": "sub_value3",
          "used": false
      },
      "key1": {
          "sub_key1": "sub_value1",
          "sub_key2": "sub_value2",
          "sub_key3": "sub_value3",
          "used": true
      },
      "key2": {
          "sub_key1": "sub_value1",
          "sub_key2": "sub_value2",
          "sub_key3": "sub_value3",
          "used": false
      },
      "key3": {
          "sub_key1": "sub_value1",
          "sub_key2": "sub_value2",
          "sub_key3": "sub_value3",
          "used": true
      },
      "key4": {
          "sub_key1": "sub_value1",
          "sub_key2": "sub_value2",
          "sub_key3": "sub_value3",
          "used": false
      },
      "key5": {
          "sub_key1": "sub_value1",
          "sub_key2": "sub_value2",
          "sub_key3": "sub_value3",
          "used": true
      }
  }
  </code></pre>
  
  <p>I have created Swift parent and child structs for it like this:</p>
  
  <p>Parent:</p>
  
  <pre><code>struct Parent: Codable {
      let id: Child?
      let key1: Child?
      let key2: Child?
      let key3: Child?
      let key4: Child?
      let key5: Child?
  }
  </code></pre>
  
  <p>Child:</p>
  
  <pre><code>struct Child: Codable {
      let sub_key1: String?
      let sub_key2: String?
      let sub_key3: String?
      let used: Bool?
  }
  </code></pre>
  
  <p>Now, only some of the Child objects are being used, depending on the 'used' property, and I would like to filter out the unused Child objects. I thought about using the <a href="https://developer.apple.com/documentation/swift/array/3017522-map" rel="nofollow noreferrer">map</a> method, but that only works for arrays.</p>
  
  <p>Any ideas on how I could go about solving this problem?</p>