ChangedenCZD edited a comment on issue #284:
URL: 
https://github.com/apache/dubbo-go-hessian2/issues/284#issuecomment-948412649


   你试试统一用
   ```go
   type MerchantResponse struct {
       Code    string
       Message string
       Data    interface{}
   }
   
   func (MerchantResponse) JavaClassName() string {
       return "com.xxx.common.Result"
   }
   ```
   再通过反射处理Data
   ```go
   
   func req() {
   res, err := api.List()
   
   switch unpackType(reflect.TypeOf(res)) {
   case reflect.Slice:
     if res0, ok := res.([]interface{}); ok {
       for _, v := range res0 {
         item := decode(v)
       }
     }
   default:
     item := decode(res)
   }
   }
   
   func decode(o interface{}) *Merchant {
     resJson, err := json.Marshal(o)
     result := &Merchant{}
     _ =  json.Unmarshal(resJson, result)
     return result
   }
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to