|
@@ -108,5 +108,10 @@ func (response *Response) Body() []byte {
|
|
|
}
|
|
|
|
|
|
func (response *Response) Json(resp any) error {
|
|
|
- return json.Unmarshal(response.response.Body(), resp)
|
|
|
-}
|
|
|
+ body := response.response.Body()
|
|
|
+ if body == nil || len(body) == 0 {
|
|
|
+ return errors.New("响应体为空")
|
|
|
+ }
|
|
|
+
|
|
|
+ return json.Unmarshal(body, resp)
|
|
|
+}
|