From d5db65128251fbae78c52b47dd0ef9fd3f17b077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Wed, 25 Sep 2024 17:26:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- define.go | 2 +- filter.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/define.go b/define.go index a80d083..e121323 100644 --- a/define.go +++ b/define.go @@ -14,7 +14,7 @@ package filter // Date : 12:21 2022/7/4 type MapRule struct { SourcePath string `json:"source_path"` // 原路径 - MapPath string `json:"map_path"` // 映射路径 + TargetPath string `json:"target_path"` // 目标路径路径 Required bool `json:"required"` // 必须存在 DataType string `json:"data_type"` // 数据类型 DefaultValue string `json:"default_value"` // 默认值, 以字符串传入, 会转换成 DataType diff --git a/filter.go b/filter.go index dcd4a81..e9055c2 100644 --- a/filter.go +++ b/filter.go @@ -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, ".") }