http/json.go
func JsonRead(body io.ReadCloser, obj interface{}, w http.ResponseWriter) bool {
	content, err := ioutil.ReadAll(io.LimitReader(body, HTTP_BODY_MAX_LENGTH))
	if err != nil {
		jerr := NewJsonErrorFromError(http.StatusInternalServerError, err)
		JsonWrite(w, jerr.Status, jerr)
		return false
	}

	if err := body.Close(); err != nil {
		jerr := NewJsonErrorFromError(http.StatusInternalServerError, err)
		JsonWrite(w, jerr.Status, jerr)
		return false
	}

	if err := json.Unmarshal(content, obj); err != nil {
		jerr := NewJsonErrorFromError(StatusUnprocessableEntity, err)
		JsonWrite(w, jerr.Status, jerr)
		return false
	}

	return true
}
func JsonRead(body io.ReadCloser, obj interface{}, w http.ResponseWriter) bool {
	content, err := ioutil.ReadAll(io.LimitReader(body, HTTP_BODY_MAX_LENGTH))
	if err != nil {
		jerr := NewJsonErrorFromError(http.StatusInternalServerError, err)
		JsonWrite(w, jerr.Status, jerr)
		return false
	}

	if err := body.Close(); err != nil {
		jerr := NewJsonErrorFromError(http.StatusInternalServerError, err)
		JsonWrite(w, jerr.Status, jerr)
		return false
	}

	if err := json.Unmarshal(content, obj); err != nil {
		jerr := NewJsonErrorFromError(StatusUnprocessableEntity, err)
		JsonWrite(w, jerr.Status, jerr)
		return false
	}

	return true
}
func JsonRead ( body io . ReadCloser , obj interface { } , w http . ResponseWriter ) bool { content , err := ioutil . ReadAll ( io . LimitReader ( body , HTTP_BODY_MAX_LENGTH ) ) if err != nil { jerr := NewJsonErrorFromError ( http . StatusInternalServerError , err ) JsonWrite ( w , jerr . Status , jerr ) return false } if err := body . Close ( ) ; err != nil { jerr := NewJsonErrorFromError ( http . StatusInternalServerError , err ) JsonWrite ( w , jerr . Status , jerr ) return false } if err := json . Unmarshal ( content , obj ) ; err != nil { jerr := NewJsonErrorFromError ( StatusUnprocessableEntity , err ) JsonWrite ( w , jerr . Status , jerr ) return false } return true }
// JsonRead tries to read client sent content using JSON deserialization and
// writes it to defined object.
JsonRead tries to read client sent content using JSON deserialization and writes it to defined object .