github.com/wfusion/gofusion@v1.1.14/http/parser/application_json.go (about)

     1  package parser
     2  
     3  import (
     4  	"io"
     5  	"reflect"
     6  
     7  	"github.com/wfusion/gofusion/common/utils/serialize/json"
     8  )
     9  
    10  type ApplicationJsonParser struct{}
    11  
    12  func (a *ApplicationJsonParser) PreParse(args map[string]string) error {
    13  	return nil
    14  }
    15  
    16  func (a *ApplicationJsonParser) Parse(src io.Reader, dst reflect.Value) (err error) {
    17  	if err = json.NewDecoder(src).Decode(dst.Addr().Interface()); err != nil {
    18  		return malformedRequest(err.Error())
    19  	}
    20  
    21  	return
    22  }