// writeJSON is a helper function for writing HTTP JSON data
writeJSON is a helper function for writing HTTP JSON data
// writeJSON is a helper function for writing HTTP JSON data
func writeJSON(w http.ResponseWriter, data interface{}) error {
	w.Header().Set("Content-Type", "application/json")
	if err := json.NewEncoder(w).Encode(data); err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		w.Write([]byte(fmt.Sprintf(`{"error":"%s","error_type":"json"}`, err)))
		return err
	}
	return nil
}
func writeJSON ( w http . ResponseWriter , data interface { } ) error { w . Header ( ) . Set ( " " , " " ) if err := json . NewEncoder ( w ) . Encode ( data ) ; err != nil { w . WriteHeader ( http . StatusInternalServerError ) w . Write ( [ ] byte ( fmt . Sprintf ( `{"error":"%s","error_type":"json"}` , err ) ) ) return err } return nil }
writeJSON is a helper function for writing HTTP JSON data
writeJSON is a helper function for writing HTTP JSON data