func Write(w http.ResponseWriter, body Body, statuses ...int) error {
	w.Header().Set("Content-Type", "application/json")
	if len(statuses) > 0 {
		w.WriteHeader(statuses[0])
	}
	b, err := json.Marshal(body)
	if err != nil {
		return err
	}
	_, err = w.Write(b)
	return err
}
Write writes the body to http.ResponseWriter.

If necessary, the status code can be specified through the third parameter.
package jsend
import (
	"encoding/json"
	"net/http"
)
const (
	StatusError   = "error"
	StatusFail    = "fail"
	StatusSuccess = "success"
)
type Body struct {
	Status  string      `json:"status"`
	Data    interface{} `json:"data,omitempty"`
	Message string      `json:"message,omitempty"`
	Code    int         `json:"code,omitempty"`
}
func New(data interface{}) Body {
	return Body{
		Status: StatusSuccess,
		Data:   data,
	}
}
func NewFail(data interface{}) Body {
	return Body{
		Status: StatusFail,
		Data:   data,
	}
}
func NewError(message string, code int, data interface{}) Body {
	return Body{
		Status:  StatusError,
		Message: message,
		Code:    code,
		Data:    data,
	}
}
func Error(w http.ResponseWriter, message string, statuses ...int) error {
	return Write(w, NewError(message, 0, nil), statuses...)
}
func ErrorCode(w http.ResponseWriter, message string, code int, statuses ...int) error {
	return Write(w, NewError(message, code, nil), statuses...)
}
func ErrorCodeData(w http.ResponseWriter, message string, code int, data interface{}, statuses ...int) error {
	return Write(w, NewError(message, code, data), statuses...)
}
func Fail(w http.ResponseWriter, data interface{}, statuses ...int) error {
	return Write(w, NewFail(data), statuses...)
}
func Success(w http.ResponseWriter, data interface{}, statuses ...int) error {
	return Write(w, New(data), statuses...)
}