title: How to show array values in different forms?
body: <p>I need to implement such form</p>
  <p><a href="https://i.stack.imgur.com/Uglzc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Uglzc.png" alt="enter image description here" /></a></p>
  <p>I get json data from server:</p>
  <pre><code>&quot;category_attributes&quot;: [
      [
          {
              &quot;name&quot;: &quot;IPhone&quot;,
              &quot;terms&quot;: [
                  {
                      &quot;name&quot;: &quot;iPhone 11&quot;
                  },
                  {
                      &quot;name&quot;: &quot;iPhone 12&quot;
                  }
              ],
          },
          {
              &quot;name&quot;: &quot;Memory&quot;,
              &quot;terms&quot;: [
                  {
                      &quot;name&quot;: &quot;1024&quot;
                  },
                  {
                      &quot;name&quot;: &quot;128&quot;
                  }
              ]
          }
      ]
  ]
  
  struct EachCategory: Decodable, Hashable {
      let name: String
      let category_attributes: [[CategoriesAttributes]]
  }
  
  struct CategoriesAttributes: Decodable, Hashable {
      let name: String
      let terms: [CateroriesTerms]
  }
  
  struct CateroriesTerms: Decodable, Hashable {
      let name: String
  }
  </code></pre>
  <p>I need to show first object's values of terms array inside buttons, and memory in dropdown list. I can only show all array values in buttons <a href="https://imgur.com/a/ZPydwmE" rel="nofollow noreferrer">https://imgur.com/a/ZPydwmE</a> How can I show only first object in buttons, and other objects in different form?</p>
  <pre><code>VStack(alignment: .leading) {
                  ForEach(viewModel.categoryAttributes, id: \.self) { category in
                      ForEach(category, id: \.self) { attribute in
                      Text(attribute.name)
                      HStack {
                      ForEach(attribute.terms, id: \.self) { term in
                      Button {
                          print(&quot;Phone model is selected&quot;)
                      } label: {
                          Text(&quot;\(term.name)&quot;)
                              .padding()
                              .foregroundColor(Color.textFieldGrayColor)
                      }.background(Color.grayButton)
                              .cornerRadius(10)
                              .frame(height: 50)
                      }
                      }
                  }
                  }
              }
  </code></pre>