title: Accessing nested array values in swiftui?
body: <p>I have a nested array that I'm working with.</p>
  <p>I need to access some values from this nested array.</p>
  <p>I can access the Root values but not the nested values with my code.</p>
  <p>This my current code:</p>
  <pre><code>    // MARK: - Root
      struct RootD: Codable {
          let id: Int
          let books: String
          let regs: [SightingsD]
          
      
          enum CodingKeys: String, CodingKey {
              case id = &quot;id&quot;
              case serial = &quot;books&quot;
              case regs = &quot;regs&quot;
          }
      }
      
      
      struct SightingsD: Codable, Identifiable {
          public var id: Int
          public var regNo: String
       
      
          
          enum CodingKeys: String, CodingKey {
              case id = &quot;id&quot;
              case regNo = &quot;regNo&quot;
      
              }
      }
  
  </code></pre>
  <p><strong>And I can access the Root stuff like this:</strong></p>
  <pre><code>          if let str = String(data: data!, encoding: .utf8) {
               
                  let data = str.data(using: .utf8)!
                  do {
                      if let jsonArray = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? NSDictionary
                      {
  
                          books = jsonArray[&quot;books&quot;] as! String
  
                          
                      } else {
                          print(&quot;bad json&quot;)
                      }
                  } catch let error as NSError {
                      print(error)
                  }
  
              }
  
  </code></pre>
  <p>But how can I access stuff like <code>regNo</code> ?</p>