func parsePayload(val map[string]string, payloadS *[]byte, values map[string]string) error { var payload interface{} if err := json.Unmarshal(*payloadS, &payload); err != nil { return err } for name, jpath := range values { var value string if scan.ScanTree(payload, jpath, &value) == nil { val[name] = value } } return nil }
// UnmarshalJSON create job object from data(JSON format). // Use jobex value loaded by LoadJobex function if the parameter is null. func (j *Job) UnmarshalJSON(data []byte) error { var i interface{} if err := json.Unmarshal(data, &i); err != nil { return err } if err := scan.ScanTree(i, "/name", &j.Name); err != nil { return err } j.importJobex() // scan.ScanTree does not change value of 3rd parameter when error occured. scan.ScanTree(i, "/node", &j.Node) scan.ScanTree(i, "/port", &j.Port) scan.ScanTree(i, "/path", &j.Path) scan.ScanTree(i, "/param", &j.Param) scan.ScanTree(i, "/env", &j.Env) scan.ScanTree(i, "/work", &j.Work) scan.ScanTree(i, "/wrc", &j.WRC) scan.ScanTree(i, "/wptn", &j.WPtn) scan.ScanTree(i, "/erc", &j.ERC) scan.ScanTree(i, "/eptn", &j.EPtn) scan.ScanTree(i, "/timeout", &j.Timeout) scan.ScanTree(i, "/snode", &j.SNode) scan.ScanTree(i, "/sport", &j.SPort) return nil }