title: How to unmarshal an array of array in go lang
body: <p>payload</p>
  <pre><code> &quot;specifications&quot;: [
          [&quot;Display&quot;, &quot;11 Inches 120 Hz Liquid Retina Display&quot;],
          [&quot;Capacity&quot;, &quot;128GB, 256GB, 512GB, 1TB, 2TB&quot;],
          [&quot;Chip&quot;, &quot;Apple M1 Chip&quot;],
          [&quot;Front Camera&quot;, &quot;12 MP : TrueDepth Camera, ƒ/2.4, 122 Degree Field of View, Animoji and Memoji, Lens Correction&quot;],
          [&quot;Rear Camera&quot;, &quot;12 MP : Wide Camera, ƒ/1.8, Five‑Element Lens, Autofocus with Focus Pixels | 10 MP : Ultra-Wide Camera, ƒ/2.4, 125 Degree Field of View, Five‑Element Lens, Lens Correction | 12MP Telephoto Camera: ƒ/2.8 Aperture&quot;],
          [&quot;Sound&quot;, &quot;Quad Speakers | AAC‑LC, HE‑AAC, HE‑AAC v2, Protected AAC, MP3, Linear PCM, Apple Lossless, FLAC, Dolby Digital (AC‑3), Dolby Digital Plus (E‑AC‑3), Dolby Atmos and Audible (formats 2, 3, 4, Audible Enhanced Audio, AAX and AAX+)&quot;],
          [&quot;WiFi&quot;, &quot;IEEE 802.11a/b/g/n/ac/ax | Dual Band (2.4 GHz and 5 GHz), HT80 with MIMO&quot;],
          [&quot;Bluetooth&quot;, &quot;Bluetooth 5.0&quot;],
          [&quot;Battery Life&quot;, &quot;Up to 10 Hours of Surfing the Web on Wi-Fi or Watching Video, Built-in 28.65 WHr Rechargeable Battery&quot;],
          [&quot;Connector&quot;, &quot;USB Type-C | 20 Watts Fast Charging, Charging Via Power Adapter or USB-C to Computer System&quot;],
          [&quot;Dimensions&quot;, &quot;7.02 x 0.23 x 9.74 Inches&quot;],
          [&quot;Weight&quot;, &quot;466 g&quot;],
          [&quot;In the Box&quot;, &quot;1 U Tablet | Power Adapter | USB Cable | Quick Start Guide | Warranty Card&quot;],
          [&quot;Warranty&quot;, &quot;12 Months | International Travellers | Carry-In&quot;]
      ],
  </code></pre>
  <p>I did made a struct but i get following error <strong>json: cannot unmarshal array into Go struct field Product.specifications of type string</strong></p>
  <p>my struct</p>
  <pre><code>type Specifications struct {
      Item *[]string
  }
  </code></pre>
  <p>product struct is</p>
  <pre><code>type Product struct {
      ID                  primitive.ObjectID `json:&quot;_id&quot; bson:&quot;_id&quot;`
      Product_Id          *string            `json:&quot;user_id&quot;`
      Category            *string            `json:&quot;category&quot;`
      Name                *string            `json:&quot;name&quot;`
      Color               *[]Color           `json:&quot;color&quot;`
      Size                *[]string          `json:&quot;size&quot;`
      Specifications      *[]string          `json:&quot;specifications&quot;`
      Product_Images      ProductImage       `json:&quot;product_image&quot;`
      Product_Accessories *[]string          `json:&quot;product_accessories&quot;`
      Product_Price       ProductPrice       `json:&quot;product_price&quot;`
  }
  </code></pre>
  <p>i intend to make a api controller</p>
  <pre><code>func ProductCreate() gin.HandlerFunc {
      return func(c *gin.Context) {
          var payload models.Product
  
          var ctx, cancel = context.WithTimeout(context.Background(), 100*time.Second)
          defer cancel()
  
          if err := c.BindJSON(&amp;payload); err != nil {
              c.JSON(400, gin.H{&quot;message&quot;: locals.InternalServerError, &quot;details&quot;: err.Error()})
              return
          }
  
          if _, err := productCollection.InsertOne(ctx, payload); err != nil {
              fmt.Println(&quot;User data not created&quot;)
              c.JSON(400, gin.H{&quot;message&quot;: locals.InternalServerError})
              return
          }
          c.JSON(200, gin.H{&quot;message&quot;: payload})
      }
  
  }
  </code></pre>
  <p>i'm currently learning about go lang, so i might be wrong please do correct me</p>