mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-18 14:52:18 +08:00
Update json.go
This commit is contained in:
parent
1473b34fd4
commit
4c44b661a4
@ -66,8 +66,8 @@ func (r JSON) WriteContentType(w http.ResponseWriter) {
|
|||||||
// WriteJSON marshals the given interface object and writes it with custom ContentType.
|
// WriteJSON marshals the given interface object and writes it with custom ContentType.
|
||||||
func WriteJSON(w http.ResponseWriter, obj interface{}) error {
|
func WriteJSON(w http.ResponseWriter, obj interface{}) error {
|
||||||
writeContentType(w, jsonContentType)
|
writeContentType(w, jsonContentType)
|
||||||
if _, isJson := r.Data.([]byte); isJson {
|
if _, isJson := obj.([]byte); isJson {
|
||||||
_, err = w.Write(jsonBytes)
|
_, err := w.Write(obj.([]byte))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
jsonBytes, err := json.Marshal(obj)
|
jsonBytes, err := json.Marshal(obj)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user