Commit 559ca15b authored by duanjinfei's avatar duanjinfei

update json marshal encoding

parent ff6354a4
...@@ -39,12 +39,12 @@ type TaskResult struct { ...@@ -39,12 +39,12 @@ type TaskResult struct {
} }
type ApiResp struct { type ApiResp struct {
TaskId string `json:"task_id"` TaskId string `json:"task_id"`
TaskResult []byte `json:"task_result"` TaskResult []string `json:"task_result"`
TaskUid string `json:"task_uid"` TaskUid string `json:"task_uid"`
TaskFee string `json:"task_fee"` TaskFee string `json:"task_fee"`
IsSuccess bool `json:"is_success"` IsSuccess bool `json:"is_success"`
TaskError string `json:"task_error"` TaskError string `json:"task_error"`
} }
type HardwareRequire struct { type HardwareRequire struct {
......
...@@ -289,23 +289,23 @@ func (t *TaskHandler) ComputeTaskHandler(taskMsg *nodeManagerV1.PushTaskMessage) ...@@ -289,23 +289,23 @@ func (t *TaskHandler) ComputeTaskHandler(taskMsg *nodeManagerV1.PushTaskMessage)
} }
} }
if len(apiRes) > 1 { if len(apiRes) > 1 {
fileCacheBody := bytes.NewBuffer([]byte{})
encoder := json.NewEncoder(fileCacheBody)
encoder.SetEscapeHTML(false)
err := encoder.Encode(apiRes)
if err != nil {
log.WithError(err).Error("encoder Encode")
}
res := &models.ApiResp{ res := &models.ApiResp{
IsSuccess: true, IsSuccess: true,
TaskResult: fileCacheBody.Bytes(), TaskResult: apiRes,
} }
apiResBody, err := json.Marshal(res) apiResBody := bytes.NewBuffer([]byte{})
encoder := json.NewEncoder(apiResBody)
encoder.SetEscapeHTML(false)
err := encoder.Encode(res)
if err != nil { if err != nil {
log.WithError(err).Error("json marshal upload oss uri") log.WithError(err).Error("encoder Encode")
} }
log.WithField("apiResBody", string(apiResBody)).Info("model resp") //apiResBody, err := json.Marshal(res)
taskExecResult.TaskRespBody = apiResBody //if err != nil {
// log.WithError(err).Error("json marshal upload oss uri")
//}
log.WithField("apiResBody", string(apiResBody.Bytes())).Info("model resp")
taskExecResult.TaskRespBody = apiResBody.Bytes()
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment