func Json(jsonStruct interface{}, ifacePtr ...interface{}) martini.Handler {
	return func(context martini.Context, req *http.Request) {
		var errors Errors

		ensureNotPointer(jsonStruct)

		jsonStruct := reflect.New(reflect.TypeOf(jsonStruct))

		if req.Body != nil {
			defer req.Body.Close()
			err := json.NewDecoder(req.Body).Decode(jsonStruct.Interface())
			if err != nil && err != io.EOF {
				errors.Add([]string{}, DeserializationError, err.Error())
			}
		}

		validateAndMap(jsonStruct, context, errors, ifacePtr...)
	}
}
func Json(jsonStruct interface{}, ifacePtr ...interface{}) martini.Handler {
	return func(context martini.Context, req *http.Request) {
		var errors Errors

		ensureNotPointer(jsonStruct)

		jsonStruct := reflect.New(reflect.TypeOf(jsonStruct))

		if req.Body != nil {
			defer req.Body.Close()
			err := json.NewDecoder(req.Body).Decode(jsonStruct.Interface())
			if err != nil && err != io.EOF {
				errors.Add([]string{}, DeserializationError, err.Error())
			}
		}

		validateAndMap(jsonStruct, context, errors, ifacePtr...)
	}
}
func Json ( jsonStruct interface { } , ifacePtr ... interface { } ) martini . Handler { return func ( context martini . Context , req * http . Request ) { var errors Errors ensureNotPointer ( jsonStruct ) jsonStruct := reflect . New ( reflect . TypeOf ( jsonStruct ) ) if req . Body != nil { defer req . Body . Close ( ) err := json . NewDecoder ( req . Body ) . Decode ( jsonStruct . Interface ( ) ) if err != nil && err != io . EOF { errors . Add ( [ ] string { } , DeserializationError , err . Error ( ) ) } } validateAndMap ( jsonStruct , context , errors , ifacePtr ... ) } }
// Json is middleware to deserialize a JSON payload from the request
// into the struct that is passed in. The resulting struct is then
// validated, but no error handling is actually performed here.
// An interface pointer can be added as a second argument in order
// to map the struct to a specific interface.
Json is middleware to deserialize a JSON payload from the request into the struct that is passed in . The resulting struct is then validated but no error handling is actually performed here . An interface pointer can be added as a second argument in order to map the struct to a specific interface .