title: How to convert the array object data to string format data using golang?
body: <p>There is an <strong>array object</strong> which is retrieved from mongodb. The data looks like below:-</p>
  
  <pre><code>[{
    1 
    fruits 
    Apple 
    Apple is my favorite fruit.
   }
   {
    2 
    colors 
    Red 
    Red color is always charming.
   } 
   {
    3 
    flowers 
    Lotus 
    It is one of the most beautiful flowers in this world.
   }]
  </code></pre>
  
  <p>This is the code for retrieving the above data 
  The struct is:</p>
  
  <pre><code>type Item struct {
    Id          int    `json:"id"`
    Category    string `json:"category"`
    Name        string `json:"name"`
    Description string `json:"description"`
  }
  type Items []Item
  
  func GetData(Query interface{}) (result Items, err error) {
      mongoSession := ConnectDb()
      sessionCopy := mongoSession.Copy()
      defer sessionCopy.Close()
      getCollection := mongoSession.DB("custom").C("custom")
      err = getCollection.Find(Query).All(&amp;result)
      if err != nil {
          return result, err
      }
      return result, nil
  }
  /*
   *  Retrieve the data used by main function
   */
  func retrieve(c *gin.Context) {
    //mongoSession := ConnectDb()
    conditions := bson.M{}
    data, err :=GetData(conditions)
    if err != nil {
      fmt.Println("There is somthing wrong")
    }
    arrange(data)
    return
  }
  
  func arrange(data Items) {
    pagesJson, err := json.Marshal(data)
    if err != nil {
      log.Fatal("Cannot encode to JSON ", err)
    }
    fmt.Println(string(pagesJson))
  }
  </code></pre>
  
  <p>Running <code>json.Marshal</code>, the output looks like below:</p>
  
  <pre><code>[{
    "id":1,
    "category":"fruits",
    "name":"Apple",
    "description":"Apple is my favorite fruit."
  },
  {
    "id":2,
    "category":"colors",
    "name":"Red",
    "description":"Red color is always charming."
  },
  {
    "id":3,
    "category":"flowers",
    "name":"Lotus",
    "description":"It is one of the most beautiful flowers in this world."
  }]
  </code></pre>
  
  <p>Expected output</p>
  
  <pre><code>{
    "id":1,
    "category":"fruits",
    "name":"Apple",
    "description":"Apple is my favorite fruit."
  }
  {
    "id":2,
    "category":"colors",
    "name":"Red",
    "description":"Red color is always charming."
  }
  {
    "id":3,
    "category":"flowers",
    "name":"Lotus",
    "description":"It is one of the most beautiful flowers in this world."
  }
  </code></pre>
  
  <p>The issue is the data is in the array object for my use I need the String structure data between <code>{}</code> as shown above. I posted this question before but not getting any success answer. I am trying it from a lot of time help me thankyou.</p>