Categories
How to add field to json?
How can I add the "status" field to "data" ?
func (r JsonResponse) SuccessResponse(w http.ResponseWriter, body interface{}) { data, err := json.Marshal(body) }
Answer the question
In order to leave comments, you need to log in
data, err := json.Marshal(body) if err != nil { log.Println(err) } w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusOK) _, _ = w.Write(data)
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question