I have function as below

I have function as below

func Get DataById(w http.ResponseWriter, r *http.Request) {
 uid := "11111"
 data := models.GetTransport(uid)

 w.WriteHeader(http.StatusOK) //200
 if data == nil {
 resp := u.Message(false, "Can not found")
 u.Respond(w, resp)
 } else {
 resp := u.Message(true, "success")
 resp["data"] = data
 u.Respond(w, resp)
 }
}


End it was response data

{
"data": [
{
"day": 1,
"begin": "AAAA",
},
{
"day": 1,
"begin": "BBBB",
},
{
"day": 2,
"begin": "CCCC",
},
{
"day": 2,
"begin": "DDDD",
},
]
}

But I want group by Day and output json as below


{
 "data": [
  "day1:" [
  {
  "begin": "AAAA",
  },
  {
 "begin": "BBBB",
  },
]
  "day2:" [
{
  "begin": "CCCC",
  },
  {
 "begin": "DDDD",
  },
] 
  ]
}


*How can I do it, please give me advice.Thanks a lot*




-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/126392e0-f702-42eb-bade-cbd68fbe8537o%40googlegroups.com.

Reply via email to