Open giantcroc opened 4 months ago
都base64了,为何不搞成string呢?
ApplyRequest {
Task string `json:"task"`
}
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
It’s all base64, why not make it a string?
ApplyRequest { Task string `json:"task"` }
都base64了,为何不搞成string呢?
ApplyRequest { Task string `json:"task"` }
We use json.Marshal(ApplyRequest)
to process the request struct in client,and base64 encoded data is the result of this process.
Go-zero will not help you with type conversion, so your data type must be consistent with the input parameters.
Go-zero will not help you with type conversion, so your data type must be consistent with the input parameters.
func unmarshalJsonReader(reader io.Reader, v any, unmarshaler *Unmarshaler) error { // var m any if err := jsonx.UnmarshalFromReader(reader, &v); err != nil { return err } return nil // return unmarshaler.Unmarshal(m, v) }
I have tested to remove
unmarshaler.Unmarshal
, it works to process[]byte
correctly. So why do we need to split the unmarshal to two processes, one forstring
tomap[string]any
, another formap[string]any
tov
?
Describe the bug httpx.parse error when the field's type in request is []byte and I post the data body after json Marshal like '{"task":"base64 encoded data"}'.
To Reproduce Steps to reproduce the behavior, if applicable:
The code is
The error is
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Environments (please complete the following information):
More description Add any other context about the problem here.