title: how to solve interface {} is string, not []uint8 in golang?
body: <p>I want to do the read and write operation in the json file. I made a program for this But there is an error which occure while Unmarshalling the datathe code is given below:-</p>
  <pre><code>package main
  
  import (
    &quot;encoding/json&quot;
    &quot;fmt&quot;
    &quot;io/ioutil&quot;
  )
  
  type Page struct {
    Id           int    `json:&quot;_id&quot; bson:&quot;_id&quot;`
    Title        string `json:&quot;title&quot; bson:&quot;title&quot;`
    Type         string `json:&quot;type&quot; bson:&quot;type&quot;`
    Description  string `json:&quot;description&quot; bson:&quot;description&quot;`
    ProfileImage string `json:&quot;profile_image&quot; bson:&quot;profile_image&quot;`
    DateTime     int64  `json:&quot;date_time&quot; bson:&quot;date_time&quot;`
    Author       string `json:&quot;author&quot; bson:&quot;author&quot;`
    Status       int    `json:&quot;status&quot; bson:&quot;status&quot;`
    Slug         string `json:&quot;slug&quot; bson:&quot;slug&quot;`
  }
  
  func main() {
     plan, _ := ioutil.ReadFile(&quot;page.json&quot;)
     var data interface{}
     err := json.Unmarshal(plan, &amp;data)
     if err != nil {
      fmt.Println(err)
     }
     if sl, ok := data.([]interface{}); ok {
       counter := 0
        for _, val := range sl {
          counter++
          md, _ := val.(map[string]interface{})
          md[&quot;_id&quot;] = counter
          fmt.Println(md[&quot;_id&quot;])
          for _, k := range md {
              // fmt.Println(k.([]byte))
              rankings := Page{}
              err = json.Unmarshal(k.([]uint8), &amp;rankings)
              if err != nil {
                  // nozzle.printError(&quot;opening config file&quot;, err.Error())
              }
  
              rankingsJson, _ := json.Marshal(rankings)
              err = ioutil.WriteFile(&quot;output.json&quot;, rankingsJson, 0644)
              fmt.Printf(&quot;%+v&quot;, rankings)
          }
        }
     }
  }
  </code></pre>
  <p>It gives me the error of</p>
  <blockquote>
  <p>panic: interface conversion: interface {} is string, not []uint8</p>
  <p>goroutine 1 [running]:</p>
  <p>main.main()</p>
  <p>/home/iron/go/src/test/json_object_read/main.go:38 +0x545</p>
  </blockquote>
  <p>Edited :-</p>
  <pre><code>[{
      &quot;title&quot;: &quot;Home Page&quot;,
      &quot;type&quot;: &quot;Home Page&quot;,
      &quot;description&quot;: &quot;On this Page you will get all the little discription about the all sections of the theme.&quot;,
      &quot;profile_image&quot;: &quot;/home.png&quot;,
      &quot;author&quot;: &quot;Bookingkoala&quot;,
      &quot;status&quot;: 1,
      &quot;slug&quot;: &quot;home-page&quot;
  },
  {
      &quot;title&quot;: &quot;Booking Page&quot;,
      &quot;type&quot;: &quot;Booking&quot;,
      &quot;description&quot;: &quot;On this page you will do Booking in 60 seconds&quot;,
      &quot;profile_image&quot;: &quot;/Booking.png&quot;,
      &quot;author&quot;: &quot;Bookingkoala&quot;,
      &quot;status&quot;: 1,
      &quot;slug&quot;: &quot;booking-page&quot;
  },
  {
      &quot;title&quot;:&quot;Gift Cards&quot;,
      &quot;type&quot;:&quot;Cards&quot;,
      &quot;description&quot;:&quot;On this page you will get the Gift cards on Special Days like:- Mother Day, Friendship Day, Father Day, etc.&quot;,
      &quot;profile_image&quot;:&quot;/Gift.jpg&quot;,
      &quot;author&quot;:&quot;Bookingkoala&quot;,
      &quot;status&quot;:1,
      &quot;slug&quot;:&quot;gift-cards&quot;
  },
  {
      &quot;title&quot;:&quot;Contact Us&quot;,
      &quot;type&quot;:&quot;Contact Information&quot;,
      &quot;description&quot;:&quot;On Contact Us Page you will get the Contact information of the merchant.&quot;,
      &quot;profile_image&quot;:&quot;/Contact.jpg&quot;,
      &quot;author&quot;:&quot;Bookingkoala&quot;,
      &quot;status&quot;:1,
      &quot;slug&quot;:&quot;contact-us&quot; 
  },
  {
      &quot;title&quot;:&quot;Services&quot;,
      &quot;type&quot;:&quot;Services&quot;,
      &quot;description&quot;:&quot;This service page will show you that which services bookingkoala has been provided&quot;,
      &quot;profile_image&quot;:&quot;/services.jpg&quot;,
      &quot;author&quot;:&quot;Bookingkoala&quot;,
      &quot;status&quot;:1,
      &quot;slug&quot;:&quot;services&quot;
  },
  {
      &quot;title&quot;:&quot;About Us&quot;,
      &quot;type&quot;:&quot;About the organisation&quot;,
      &quot;description&quot;:&quot;Most are targeted towards shareholders and aren't interesting for their customers, but Adidas breaks the mold.While most of the information is still geared towards shareholders, the athletic company's presentation is easily digestible and nicely organized.&quot;,
      &quot;profile_image&quot;:&quot;/aboutus.jpg&quot;,
      &quot;author&quot;:&quot;Bookingkoala&quot;,
      &quot;status&quot;:1,
      &quot;slug&quot;:&quot;about-us&quot;
  },
  {
      &quot;title&quot;:&quot;Referrals&quot;,
      &quot;type&quot;:&quot;referrals&quot;,
      &quot;description&quot;:&quot;This will give you the money in you wallte on each share.&quot;,
      &quot;profile_image&quot;:&quot;/referrals.jpg&quot;,
      &quot;author&quot;:&quot;Bookingkoala&quot;,
      &quot;status&quot;:1,
      &quot;slug&quot;:&quot;referrals&quot;
  },
  {
      &quot;title&quot;:&quot;Login/SignUp&quot;,
      &quot;type&quot;:&quot;Login/SignUp&quot;,
      &quot;description&quot;:&quot;Via This page you will enter to the theme.&quot;,
      &quot;profile_image&quot;:&quot;/login.jpg&quot;,
      &quot;author&quot;:&quot;Bookingkoala&quot;,
      &quot;status&quot;:1,
      &quot;slug&quot;:&quot;login&quot;
  },
  {
      &quot;title&quot;:&quot;Terms/Services&quot;,
      &quot;type&quot;:&quot;Terms/Services&quot;,
      &quot;description&quot;:&quot;This page tells you the term and conditions.&quot;,
      &quot;profile_image&quot;:&quot;/services_and_terms.jpg&quot;,
      &quot;author&quot;:&quot;Bookingkoala&quot;,
      &quot;status&quot;:1,
      &quot;slug&quot;:&quot;terms&quot;
  },
  {
      &quot;title&quot;:&quot;Privacy Policy&quot;,
      &quot;type&quot;:&quot;Privacy Policy&quot;,
      &quot;description&quot;:&quot;A privacy policy is a legal document that details how a website gathers, stores, shares, and sells data about its visitors. This data typically includes items such as a user's name, address, birthday, marital status, medical history, and consumer behavior. The specific contents of this document depend upon the laws in the legal jurisdiction in which your business operates. Most countries have their own set of guidelines regarding what information is eligible for collection, and how that information may be used.&quot;,
      &quot;profile_image&quot;:&quot;/privacy.jpg&quot;,
      &quot;author&quot;:&quot;Bookingkoala&quot;,
      &quot;status&quot;:1,
      &quot;slug&quot;:&quot;privacy-policy&quot;
  },
  {
      &quot;title&quot;:&quot;FAQ&quot;,
      &quot;type&quot;:&quot;FAQ&quot;,
      &quot;description&quot;:&quot;This page will Show you frequently ask questions.&quot;,
      &quot;profile_image&quot;:&quot;/faq.jpg&quot;,
      &quot;author&quot;:&quot;Bookingkoala&quot;,
      &quot;status&quot;:1,
      &quot;slug&quot;:&quot;faq&quot;
  }
  ]
  </code></pre>