优化数据结构定义

This commit is contained in:
2024-09-25 17:26:49 +08:00
parent b6a27fffd5
commit d5db651282
2 changed files with 3 additions and 3 deletions

View File

@ -67,7 +67,7 @@ func (f *filter) Deal() error {
if formatVal, err = f.getValue(rule.DataType, sourceResult, rule.DefaultValue); nil != err {
return fmt.Errorf("%s = %v can not convert to %s : %s", rule.SourcePath, sourceResult.Value(), rule.DataType, err.Error())
}
if f.formatResult, err = sjson.Set(f.formatResult, rule.MapPath, formatVal); nil != err {
if f.formatResult, err = sjson.Set(f.formatResult, rule.TargetPath, formatVal); nil != err {
return err
}
}
@ -97,7 +97,7 @@ func (f *filter) handleArray(rule MapRule) error {
for idx, item := range sourcePathArray {
sourcePathArray[idx] = strings.Trim(item, ".")
}
mapPathArray := strings.Split(strings.TrimRight(rule.MapPath, ".[]"), "[]")
mapPathArray := strings.Split(strings.TrimRight(rule.TargetPath, ".[]"), "[]")
for idx, item := range mapPathArray {
mapPathArray[idx] = strings.Trim(item, ".")
}