From efd9060fb89793fe6c6bc042b16e27c89c95aef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 28 Mar 2023 18:17:43 +0800 Subject: [PATCH 01/24] =?UTF-8?q?=E5=A2=9E=E5=8A=A0node=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tree/REDME.md | 3 +++ tree/node.go | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tree/REDME.md create mode 100644 tree/node.go diff --git a/tree/REDME.md b/tree/REDME.md new file mode 100644 index 0000000..e74d0a8 --- /dev/null +++ b/tree/REDME.md @@ -0,0 +1,3 @@ +# 说明 + +基于JSON数据生成数据树 diff --git a/tree/node.go b/tree/node.go new file mode 100644 index 0000000..17c05d2 --- /dev/null +++ b/tree/node.go @@ -0,0 +1,24 @@ +// Package tree ... +// +// Description : tree ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2023-03-28 18:12 +package tree + +// Node 节点的数据结构 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 18:12 2023/3/28 +type Node struct { + Value interface{} // 节点的值 + ValueType string // 数据类型 int64 / float64 / map / list / nil + Key string // 节点的key名称(输入的原始名称) + Show bool // 节点是否可见 + ShowKey string // 重新序列化后, 对外输出的Key + AllowEdit bool // 当前key是否允许编辑 + AllowChangeType bool // 在允许编辑的情况下, 是否允许修改数据类型 + DefaultValue interface{} // 输入为value为nil时候的默认值 +} From ed02fb1c26060465e4d020fde93cb9c1f4ec4e1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 28 Mar 2023 18:20:50 +0800 Subject: [PATCH 02/24] =?UTF-8?q?=E4=BC=98=E5=8C=96node=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tree/node.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tree/node.go b/tree/node.go index 17c05d2..4c4e411 100644 --- a/tree/node.go +++ b/tree/node.go @@ -21,4 +21,8 @@ type Node struct { AllowEdit bool // 当前key是否允许编辑 AllowChangeType bool // 在允许编辑的情况下, 是否允许修改数据类型 DefaultValue interface{} // 输入为value为nil时候的默认值 + ParentNode *Node // 父节点 + PreBrotherNode *Node // 前一个兄弟节点 + LastBrotherNode *Node // 下一个兄弟节点 + SonNodeList []*Node // 子节点列表 } From 99a5bb1888f45a56d4a7dace4ab0eb908c01061f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 28 Mar 2023 18:31:28 +0800 Subject: [PATCH 03/24] =?UTF-8?q?node=E7=BB=93=E6=9E=84=E5=BC=95=E5=85=A5?= =?UTF-8?q?=E8=99=9A=E6=8B=9F=E8=8A=82=E7=82=B9=E6=A6=82=E5=BF=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tree/node.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tree/node.go b/tree/node.go index 4c4e411..a332125 100644 --- a/tree/node.go +++ b/tree/node.go @@ -13,6 +13,7 @@ package tree // // Date : 18:12 2023/3/28 type Node struct { + IsVirtual bool // 是否虚拟节点, 主要应对输入的原始数据为list这一场景 Value interface{} // 节点的值 ValueType string // 数据类型 int64 / float64 / map / list / nil Key string // 节点的key名称(输入的原始名称) From a3b7072672bbd74ffce4c654453cbeaede73d922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 28 Mar 2023 18:39:05 +0800 Subject: [PATCH 04/24] =?UTF-8?q?=E5=A2=9E=E5=8A=A0JSON=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E8=AF=8D=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tree/consts.go | 25 +++++++++++++++++++++++++ tree/node.go | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tree/consts.go diff --git a/tree/consts.go b/tree/consts.go new file mode 100644 index 0000000..1e03547 --- /dev/null +++ b/tree/consts.go @@ -0,0 +1,25 @@ +// Package tree ... +// +// Description : tree ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2023-03-28 18:32 +package tree + +const ( + // KeywordObjectStart 对象开始标识 + KeywordObjectStart = "{" + // KeywordObjectEnd 对象结束标识 + KeywordObjectEnd = "}" + // KeywordArrayStart 数组开始标识 + KeywordArrayStart = "[" + // KeywordArrayEnd 数组结束标识 + KeywordArrayEnd = "]" + // KeywordColon 冒号 + KeywordColon = ":" + // KeywordDoubleQuote 双引号 + KeywordDoubleQuote = `"` + // KeywordEscapeSymbol 转义符号 + KeywordEscapeSymbol = `\` +) diff --git a/tree/node.go b/tree/node.go index a332125..bf8cfdb 100644 --- a/tree/node.go +++ b/tree/node.go @@ -15,7 +15,7 @@ package tree type Node struct { IsVirtual bool // 是否虚拟节点, 主要应对输入的原始数据为list这一场景 Value interface{} // 节点的值 - ValueType string // 数据类型 int64 / float64 / map / list / nil + ValueType string // 数据类型 string / int64 / float64 / map / list / nil Key string // 节点的key名称(输入的原始名称) Show bool // 节点是否可见 ShowKey string // 重新序列化后, 对外输出的Key From 41d97948c06f7ad30226864e49b1764f5b438ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 28 Mar 2023 18:42:06 +0800 Subject: [PATCH 05/24] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tree/consts.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tree/consts.go b/tree/consts.go index 1e03547..5d66254 100644 --- a/tree/consts.go +++ b/tree/consts.go @@ -23,3 +23,16 @@ const ( // KeywordEscapeSymbol 转义符号 KeywordEscapeSymbol = `\` ) + +const ( + // ValueTypeString 字符串类型 + ValueTypeString = "string" + // ValueTypeInteger int类型 + ValueTypeInteger = "int64" + // ValueTypeFloat float类型 + ValueTypeFloat = "float64" + // ValueTypeMap map数据 + ValueTypeMap = "map" + // ValueTypeArray 数组 + ValueTypeArray = "array" +) From 055c833fce71d52e5c6a7df0f8f1c287d74f326d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 28 Mar 2023 18:58:39 +0800 Subject: [PATCH 06/24] save code --- go.mod | 2 +- tree/generate.go | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tree/generate.go diff --git a/go.mod b/go.mod index af271f9..3d58812 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module git.zhangdeman.cn/zhangdeman/json_filter -go 1.17 +go 1.18 require ( git.zhangdeman.cn/zhangdeman/easylock v0.0.0-20220627070212-c590a0a1c216 diff --git a/tree/generate.go b/tree/generate.go new file mode 100644 index 0000000..c423ede --- /dev/null +++ b/tree/generate.go @@ -0,0 +1,17 @@ +// Package tree ... +// +// Description : tree ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2023-03-28 18:42 +package tree + +// New 生成一棵JSON树 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 18:42 2023/3/28 +func New(jsonData string) *Node { + return nil +} From f24fe13e4b8c2ece003f29f26dfd2b0a238bd9f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 28 Mar 2023 23:56:13 +0800 Subject: [PATCH 07/24] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=96=B0=E8=8A=82=E7=82=B9=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tree/consts.go | 11 ++++++++ tree/generate.go | 55 ++++++++++++++++++++++++++++++++++-- tree/node.go | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+), 2 deletions(-) diff --git a/tree/consts.go b/tree/consts.go index 5d66254..203b24c 100644 --- a/tree/consts.go +++ b/tree/consts.go @@ -27,6 +27,8 @@ const ( const ( // ValueTypeString 字符串类型 ValueTypeString = "string" + // ValueTypeBool bool类型 + ValueTypeBool = "bool" // ValueTypeInteger int类型 ValueTypeInteger = "int64" // ValueTypeFloat float类型 @@ -36,3 +38,12 @@ const ( // ValueTypeArray 数组 ValueTypeArray = "array" ) + +// isBaseDataType 是否为基础数据类型 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 23:16 2023/3/28 +func isBaseDataType(valueType string) bool { + return valueType != ValueTypeArray && valueType != ValueTypeMap +} diff --git a/tree/generate.go b/tree/generate.go index c423ede..09a7160 100644 --- a/tree/generate.go +++ b/tree/generate.go @@ -7,11 +7,62 @@ // Date : 2023-03-28 18:42 package tree +import "strings" + // New 生成一棵JSON树 // // Author : go_developer@163.com<白茶清欢> // // Date : 18:42 2023/3/28 -func New(jsonData string) *Node { - return nil +func New(jsonData string) *Generate { + jsonData = strings.TrimSpace(jsonData) + g := &Generate{ + jsonData: jsonData, + } + if g.isArray() { + g.root = &Node{ + IsVirtual: true, + Value: nil, + ValueType: "", + Key: "", + Show: false, + ShowKey: "", + AllowEdit: false, + AllowChangeType: false, + DefaultValue: nil, + ParentNode: nil, + PreBrotherNode: nil, + LastBrotherNode: nil, + SonNodeList: nil, + } + } + return g +} + +// Generate ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 22:46 2023/3/28 +type Generate struct { + root *Node + jsonData string +} + +// isObject 整体是否为对象 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 22:51 2023/3/28 +func (g *Generate) isObject() bool { + return strings.HasPrefix(g.jsonData, KeywordObjectStart) +} + +// isArray 整体是否为数组 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 22:51 2023/3/28 +func (g *Generate) isArray() bool { + return strings.HasPrefix(g.jsonData, KeywordArrayStart) } diff --git a/tree/node.go b/tree/node.go index bf8cfdb..52f32a4 100644 --- a/tree/node.go +++ b/tree/node.go @@ -7,6 +7,12 @@ // Date : 2023-03-28 18:12 package tree +import ( + "strings" + + "git.zhangdeman.cn/zhangdeman/util" +) + // Node 节点的数据结构 // // Author : go_developer@163.com<白茶清欢> @@ -27,3 +33,70 @@ type Node struct { LastBrotherNode *Node // 下一个兄弟节点 SonNodeList []*Node // 子节点列表 } + +// NewNode 创建新节点 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 23:02 2023/3/28 +func NewNode(key string, value string, valueType string, parentNode *Node) *Node { + n := &Node{ + IsVirtual: false, + Value: value, + ValueType: valueType, + Key: key, + Show: false, + ShowKey: "", + AllowEdit: false, + AllowChangeType: false, + DefaultValue: nil, + ParentNode: parentNode, + PreBrotherNode: nil, + LastBrotherNode: nil, + SonNodeList: nil, + } + + switch valueType { + case ValueTypeString: + n.Value = value + case ValueTypeInteger: + var v int64 + _ = util.ConvertAssign(&v, value) + n.Value = v + case ValueTypeFloat: + var v float64 + _ = util.ConvertAssign(&v, value) + n.Value = v + case ValueTypeBool: + n.Value = strings.ToLower(value) == "true" + case ValueTypeMap: + n.Value = map[string]interface{}{} + n.SonNodeList = make([]*Node, 0) + case ValueTypeArray: + n.Value = []interface{}{} + n.SonNodeList = make([]*Node, 0) + } + + // 处理 preBrother 和 lastBrother + if parentNode.ValueType == ValueTypeMap || parentNode.ValueType == ValueTypeArray { + // map 和 array 才有所谓的兄弟节点 + if len(parentNode.SonNodeList) > 0 { + // 设置新节点的 pre 节点 + n.PreBrotherNode = parentNode.SonNodeList[len(parentNode.SonNodeList)-1] + // 设置当前最后一个节点的 last 节点 + parentNode.SonNodeList[len(parentNode.SonNodeList)-1].LastBrotherNode = n + } + // 新节点追加到子节点末尾 + parentNode.SonNodeList = append(parentNode.SonNodeList, n) + } + return n +} + +// NewVirtualNode 创建一个新的虚拟节点 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 23:08 2023/3/28 +func NewVirtualNode() *Node { + return &Node{IsVirtual: true, SonNodeList: make([]*Node, 0)} +} From f30bf03b589ede0f4e0ac6087e0565ffb1926de2 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, 29 Mar 2023 14:40:59 +0800 Subject: [PATCH 08/24] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=A7=A3=E6=9E=90json?= =?UTF-8?q?=20key=E5=92=8C=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tree/consts.go | 22 ++++++++ tree/generate.go | 141 ++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 142 insertions(+), 21 deletions(-) diff --git a/tree/consts.go b/tree/consts.go index 203b24c..9a34962 100644 --- a/tree/consts.go +++ b/tree/consts.go @@ -18,10 +18,30 @@ const ( KeywordArrayEnd = "]" // KeywordColon 冒号 KeywordColon = ":" + // KeywordDot . + KeywordDot = "." // KeywordDoubleQuote 双引号 KeywordDoubleQuote = `"` // KeywordEscapeSymbol 转义符号 KeywordEscapeSymbol = `\` + // KeywordSpace 空格 + KeywordSpace = " " + // KeywordMinus 负号 + KeywordMinus = "-" + // KeywordTrueStart true的起始值 + KeywordTrueStart = "t" + // KeywordFalseStart false的起始值 + KeywordFalseStart = "f" + KeywordZero = "0" + KeywordOne = "1" + KeywordTwo = "2" + KeywordThree = "3" + KeywordFour = "4" + KeywordFive = "5" + KeywordSix = "6" + KeywordSeven = "7" + KeywordEight = "8" + KeywordNine = "9" ) const ( @@ -33,6 +53,8 @@ const ( ValueTypeInteger = "int64" // ValueTypeFloat float类型 ValueTypeFloat = "float64" + // ValueTypeNumber 数字 + ValueTypeNumber = "number" // ValueTypeMap map数据 ValueTypeMap = "map" // ValueTypeArray 数组 diff --git a/tree/generate.go b/tree/generate.go index 09a7160..4840708 100644 --- a/tree/generate.go +++ b/tree/generate.go @@ -7,7 +7,10 @@ // Date : 2023-03-28 18:42 package tree -import "strings" +import ( + "github.com/pkg/errors" + "strings" +) // New 生成一棵JSON树 // @@ -17,25 +20,11 @@ import "strings" func New(jsonData string) *Generate { jsonData = strings.TrimSpace(jsonData) g := &Generate{ - jsonData: jsonData, - } - if g.isArray() { - g.root = &Node{ - IsVirtual: true, - Value: nil, - ValueType: "", - Key: "", - Show: false, - ShowKey: "", - AllowEdit: false, - AllowChangeType: false, - DefaultValue: nil, - ParentNode: nil, - PreBrotherNode: nil, - LastBrotherNode: nil, - SonNodeList: nil, - } + jsonData: jsonData, + jsonDataByte: []byte(jsonData), } + g.root = NewVirtualNode() + g.currentNode = g.root return g } @@ -45,8 +34,118 @@ func New(jsonData string) *Generate { // // Date : 22:46 2023/3/28 type Generate struct { - root *Node - jsonData string + root *Node // 根节点 + currentNode *Node // 当前节点 + jsonData string + jsonDataByte []byte +} + +// getKey 获取jsonKey TODO : 转义符识别 +// +// Author : zhangdeman001@ke.com<张德满> +// +// Date : 11:36 2023/3/29 +func (g *Generate) getKey(startIndex int) (string, int, error) { + keyCharList := []string{} + hasStart := false + for startIndex < len(g.jsonDataByte) { + charStr := string(g.jsonDataByte[startIndex]) + if charStr == KeywordSpace { + // 跳过空格 + continue + } + if charStr == KeywordDoubleQuote && !hasStart { + // 第一次遇见双引号 + hasStart = true + } + if charStr == KeywordDoubleQuote && hasStart { + // 第二次遇见双引号,key探寻结束 + break + } + keyCharList = append(keyCharList, charStr) + startIndex++ + } + jsonKey := strings.Join(keyCharList, "") + + return jsonKey, startIndex, nil +} + +// getValueType 获取数据类型 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 14:37 2023/3/29 +func (g *Generate) getValueType(startIndex int) (string, int, error) { + // 指针向后, 探寻到冒号之后第一个非空格字符串 + hasFindColon := false + for startIndex < len(g.jsonDataByte) { + charStr := string(g.jsonDataByte[startIndex]) + if !hasFindColon { + if charStr == KeywordSpace { + // 跳过空格 + startIndex++ + continue + } + if charStr != KeywordSpace { + // 非空格 + if charStr != KeywordColon { + return "", startIndex, errors.New("value is invalid") + } + startIndex++ + hasFindColon = true + break + } + } + } + + if !hasFindColon { + return "", startIndex, errors.New("value is invalid") + } + + keyValType := "" + // 冒号后面探寻值的类型 + for startIndex < len(g.jsonDataByte) { + charStr := string(g.jsonDataByte[startIndex]) + if charStr == KeywordSpace { + // 跳过空格 + startIndex++ + continue + } + + // 非空 + switch charStr { + case KeywordMinus: + fallthrough + case KeywordOne: + fallthrough + case KeywordTwo: + fallthrough + case KeywordThree: + fallthrough + case KeywordFour: + fallthrough + case KeywordFive: + fallthrough + case KeywordSix: + fallthrough + case KeywordSeven: + fallthrough + case KeywordEight: + fallthrough + case KeywordNine: + keyValType = ValueTypeNumber + case KeywordDoubleQuote: + keyValType = ValueTypeString + case KeywordArrayStart: + keyValType = ValueTypeArray + case KeywordObjectStart: + keyValType = ValueTypeMap + default: + return "", startIndex, errors.New("value type is invalid") + } + break + } + return keyValType, startIndex, nil } // isObject 整体是否为对象 From 047935c85c30732643432d73f4e07fd375a65338 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, 29 Mar 2023 22:06:28 +0800 Subject: [PATCH 09/24] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dkey=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tree/generate.go | 77 ++++++++++++++++++++++++++++++++++++++----- tree/generate_test.go | 23 +++++++++++++ 2 files changed, 91 insertions(+), 9 deletions(-) create mode 100644 tree/generate_test.go diff --git a/tree/generate.go b/tree/generate.go index 4840708..afd8ef3 100644 --- a/tree/generate.go +++ b/tree/generate.go @@ -8,8 +8,10 @@ package tree import ( - "github.com/pkg/errors" + "fmt" "strings" + + "github.com/pkg/errors" ) // New 生成一棵JSON树 @@ -17,7 +19,7 @@ import ( // Author : go_developer@163.com<白茶清欢> // // Date : 18:42 2023/3/28 -func New(jsonData string) *Generate { +func New(jsonData string) (*Generate, error) { jsonData = strings.TrimSpace(jsonData) g := &Generate{ jsonData: jsonData, @@ -25,7 +27,8 @@ func New(jsonData string) *Generate { } g.root = NewVirtualNode() g.currentNode = g.root - return g + err := g.init() + return g, err } // Generate ... @@ -34,10 +37,49 @@ func New(jsonData string) *Generate { // // Date : 22:46 2023/3/28 type Generate struct { - root *Node // 根节点 - currentNode *Node // 当前节点 - jsonData string - jsonDataByte []byte + root *Node // 根节点 + currentNode *Node // 当前节点 + currentParentNode *Node // 当前节点的父节点 + jsonData string + jsonDataByte []byte +} + +// init 初始化 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 21:23 2023/3/29 +func (g *Generate) init() error { + startIndex := 0 + var ( + jsonKey string + err error + valueType string + ) + + // 获取类型 + if valueType, startIndex, err = g.getValueType(startIndex); nil != err { + return err + } + + g.root.ValueType = valueType + + for { + if startIndex >= len(g.jsonDataByte) { + break + } + + // 获取字段 + if jsonKey, startIndex, err = g.getKey(startIndex); nil != err { + return err + } + // 获取类型 + if valueType, startIndex, err = g.getValueType(startIndex); nil != err { + return err + } + fmt.Println(jsonKey, valueType, startIndex) + } + return nil } // getKey 获取jsonKey TODO : 转义符识别 @@ -52,14 +94,18 @@ func (g *Generate) getKey(startIndex int) (string, int, error) { charStr := string(g.jsonDataByte[startIndex]) if charStr == KeywordSpace { // 跳过空格 + startIndex++ continue } if charStr == KeywordDoubleQuote && !hasStart { // 第一次遇见双引号 + startIndex++ hasStart = true + continue } if charStr == KeywordDoubleQuote && hasStart { // 第二次遇见双引号,key探寻结束 + startIndex++ break } keyCharList = append(keyCharList, charStr) @@ -76,6 +122,19 @@ func (g *Generate) getKey(startIndex int) (string, int, error) { // // Date : 14:37 2023/3/29 func (g *Generate) getValueType(startIndex int) (string, int, error) { + if startIndex == 0 { + // 初始对象特殊处理 + if string(g.jsonDataByte[0]) == KeywordArrayStart { + return ValueTypeArray, 1, nil + } + + // 初始对象特殊处理 + if string(g.jsonDataByte[0]) == KeywordObjectStart { + return ValueTypeMap, 1, nil + } + + return "", 0, errors.New("root data parse : value is invalid") + } // 指针向后, 探寻到冒号之后第一个非空格字符串 hasFindColon := false for startIndex < len(g.jsonDataByte) { @@ -99,7 +158,7 @@ func (g *Generate) getValueType(startIndex int) (string, int, error) { } if !hasFindColon { - return "", startIndex, errors.New("value is invalid") + return "", startIndex, errors.New("check json value type : value is invalid") } keyValType := "" @@ -141,7 +200,7 @@ func (g *Generate) getValueType(startIndex int) (string, int, error) { case KeywordObjectStart: keyValType = ValueTypeMap default: - return "", startIndex, errors.New("value type is invalid") + return "", startIndex, errors.New("validate json value type : value type is invalid") } break } diff --git a/tree/generate_test.go b/tree/generate_test.go new file mode 100644 index 0000000..a124fa3 --- /dev/null +++ b/tree/generate_test.go @@ -0,0 +1,23 @@ +// Package tree ... +// +// Description : tree ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2023-03-29 21:32 +package tree + +import ( + "fmt" + "testing" +) + +func TestNew(t *testing.T) { + jsonData := `{"name": "zhang", "age":17}` + g, err := New(jsonData) + if nil != err { + fmt.Println(err.Error()) + return + } + fmt.Println(g) +} From 9bbd781a1f339f903ed65356f3a9e9e8d9206fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 30 Mar 2023 12:02:40 +0800 Subject: [PATCH 10/24] =?UTF-8?q?key=E8=A7=A3=E6=9E=90=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=BD=AC=E4=B9=89=E7=AC=A6=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tree/generate.go | 10 ++++++++++ tree/generate_test.go | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tree/generate.go b/tree/generate.go index afd8ef3..1d1a99c 100644 --- a/tree/generate.go +++ b/tree/generate.go @@ -108,6 +108,16 @@ func (g *Generate) getKey(startIndex int) (string, int, error) { startIndex++ break } + + if charStr == KeywordEscapeSymbol { + // 转义符 + startIndex++ + if startIndex >= len(g.jsonDataByte) { + // 转义符后面没东西了 + return "", startIndex, errors.New("escape symbol without any data") + } + charStr = string(g.jsonDataByte[startIndex]) + } keyCharList = append(keyCharList, charStr) startIndex++ } diff --git a/tree/generate_test.go b/tree/generate_test.go index a124fa3..c7e118b 100644 --- a/tree/generate_test.go +++ b/tree/generate_test.go @@ -13,7 +13,7 @@ import ( ) func TestNew(t *testing.T) { - jsonData := `{"name": "zhang", "age":17}` + jsonData := `{"n\\\\\\ame": "zhang", "age":17}` g, err := New(jsonData) if nil != err { fmt.Println(err.Error()) From 7530e07e7a3f69b1805d18df0a79674d6d03dcf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 30 Mar 2023 12:26:17 +0800 Subject: [PATCH 11/24] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=AE=80=E7=89=88value?= =?UTF-8?q?=E5=80=BC=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tree/consts.go | 2 ++ tree/generate.go | 50 ++++++++++++++++++++++++++++++++++++++++++- tree/generate_test.go | 2 +- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/tree/consts.go b/tree/consts.go index 9a34962..2085e53 100644 --- a/tree/consts.go +++ b/tree/consts.go @@ -18,6 +18,8 @@ const ( KeywordArrayEnd = "]" // KeywordColon 冒号 KeywordColon = ":" + // KeywordComma 逗号 + KeywordComma = "," // KeywordDot . KeywordDot = "." // KeywordDoubleQuote 双引号 diff --git a/tree/generate.go b/tree/generate.go index 1d1a99c..0789f99 100644 --- a/tree/generate.go +++ b/tree/generate.go @@ -55,6 +55,7 @@ func (g *Generate) init() error { jsonKey string err error valueType string + jsonValue string ) // 获取类型 @@ -77,7 +78,11 @@ func (g *Generate) init() error { if valueType, startIndex, err = g.getValueType(startIndex); nil != err { return err } - fmt.Println(jsonKey, valueType, startIndex) + // 获取值 + if jsonValue, err = g.getValue(startIndex); nil != err { + return err + } + fmt.Println(jsonKey, valueType, jsonValue, startIndex) } return nil } @@ -217,6 +222,49 @@ func (g *Generate) getValueType(startIndex int) (string, int, error) { return keyValType, startIndex, nil } +// getValue 获取JSON值 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 12:09 2023/3/30 +func (g *Generate) getValue(startIndex int) (string, error) { + valArr := make([]string, 0) + isStart := false + for startIndex < len(g.jsonDataByte) { + str := string(g.jsonDataByte[startIndex]) + if str == KeywordSpace { + startIndex++ + continue + } + if !isStart { + if str == KeywordArrayEnd || str == KeywordObjectEnd || str == KeywordComma { + startIndex++ + continue + } + } + if isStart { + if str == KeywordDoubleQuote || str == KeywordArrayEnd || str == KeywordObjectEnd || str == KeywordComma { + // 值的拼接已结束 + startIndex++ + break + } + } + if str == KeywordDoubleQuote { + if isStart { + startIndex++ + break + } else { + startIndex++ + continue + } + } + isStart = true + valArr = append(valArr, str) + startIndex++ + } + return strings.Join(valArr, ""), nil +} + // isObject 整体是否为对象 // // Author : go_developer@163.com<白茶清欢> diff --git a/tree/generate_test.go b/tree/generate_test.go index c7e118b..a124fa3 100644 --- a/tree/generate_test.go +++ b/tree/generate_test.go @@ -13,7 +13,7 @@ import ( ) func TestNew(t *testing.T) { - jsonData := `{"n\\\\\\ame": "zhang", "age":17}` + jsonData := `{"name": "zhang", "age":17}` g, err := New(jsonData) if nil != err { fmt.Println(err.Error()) From f760ab057ab013937d6a39cc77ea98bbaeba93bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 30 Mar 2023 13:59:27 +0800 Subject: [PATCH 12/24] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E8=A7=A3=E6=9E=90=E8=8E=B7=E5=8F=96=E5=80=BC?= =?UTF-8?q?=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tree/generate.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tree/generate.go b/tree/generate.go index 0789f99..5af3eb7 100644 --- a/tree/generate.go +++ b/tree/generate.go @@ -79,7 +79,7 @@ func (g *Generate) init() error { return err } // 获取值 - if jsonValue, err = g.getValue(startIndex); nil != err { + if jsonValue, startIndex, err = g.getValue(startIndex); nil != err { return err } fmt.Println(jsonKey, valueType, jsonValue, startIndex) @@ -102,6 +102,7 @@ func (g *Generate) getKey(startIndex int) (string, int, error) { startIndex++ continue } + if charStr == KeywordDoubleQuote && !hasStart { // 第一次遇见双引号 startIndex++ @@ -114,6 +115,14 @@ func (g *Generate) getKey(startIndex int) (string, int, error) { break } + if !hasStart { + if charStr == KeywordDoubleQuote || charStr == KeywordObjectStart || charStr == KeywordArrayStart || charStr == KeywordComma { + startIndex++ + continue + } + return "", startIndex, errors.New("parse key : format is invalid") + } + if charStr == KeywordEscapeSymbol { // 转义符 startIndex++ @@ -227,7 +236,7 @@ func (g *Generate) getValueType(startIndex int) (string, int, error) { // Author : go_developer@163.com<白茶清欢> // // Date : 12:09 2023/3/30 -func (g *Generate) getValue(startIndex int) (string, error) { +func (g *Generate) getValue(startIndex int) (string, int, error) { valArr := make([]string, 0) isStart := false for startIndex < len(g.jsonDataByte) { @@ -262,7 +271,7 @@ func (g *Generate) getValue(startIndex int) (string, error) { valArr = append(valArr, str) startIndex++ } - return strings.Join(valArr, ""), nil + return strings.Join(valArr, ""), startIndex, nil } // isObject 整体是否为对象 From 718344dcc16cd51f7c336b96b34a9ea21ca2c7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 30 Mar 2023 14:13:09 +0800 Subject: [PATCH 13/24] =?UTF-8?q?value=E8=A7=A3=E6=9E=90=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=BD=AC=E4=B9=89=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tree/generate.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tree/generate.go b/tree/generate.go index 5af3eb7..322b27f 100644 --- a/tree/generate.go +++ b/tree/generate.go @@ -268,6 +268,15 @@ func (g *Generate) getValue(startIndex int) (string, int, error) { } } isStart = true + if str == KeywordEscapeSymbol { + // 转义符 + startIndex++ + if startIndex >= len(g.jsonDataByte) { + // 转义符后面没东西了 + return "", startIndex, errors.New("escape symbol without any data") + } + str = string(g.jsonDataByte[startIndex]) + } valArr = append(valArr, str) startIndex++ } From 4629e31171996d30ebbd460bbfcaa78c879990bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 30 Mar 2023 14:32:35 +0800 Subject: [PATCH 14/24] =?UTF-8?q?=E5=9F=BA=E7=A1=80=E7=9A=84JSON=E6=A0=91?= =?UTF-8?q?=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tree/generate.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tree/generate.go b/tree/generate.go index 322b27f..aa8b844 100644 --- a/tree/generate.go +++ b/tree/generate.go @@ -64,6 +64,7 @@ func (g *Generate) init() error { } g.root.ValueType = valueType + g.currentNode.ValueType = valueType for { if startIndex >= len(g.jsonDataByte) { @@ -83,6 +84,16 @@ func (g *Generate) init() error { return err } fmt.Println(jsonKey, valueType, jsonValue, startIndex) + // 创建节点, 并挂在到树上 + var newNode *Node + if g.currentNode.ValueType == ValueTypeArray || g.currentNode.ValueType == ValueTypeMap { + newNode = NewNode(jsonKey, jsonValue, valueType, g.currentNode) + g.currentParentNode = g.currentNode + g.currentParentNode.SonNodeList = append(g.currentParentNode.SonNodeList, newNode) + } else { + newNode = NewNode(jsonKey, jsonValue, valueType, g.currentParentNode) + } + g.currentNode = newNode } return nil } From a1a1b1d2e0f783f077388125dddf35bfff4f7e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 30 Mar 2023 16:28:10 +0800 Subject: [PATCH 15/24] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20in=20=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 4 ++++ tree/generate.go | 22 +++++++++++++++------- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 3d58812..eeb28e4 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( git.zhangdeman.cn/zhangdeman/easylock v0.0.0-20220627070212-c590a0a1c216 - git.zhangdeman.cn/zhangdeman/util v0.0.0-20230211164227-256094968151 + git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330082619-662152cb682d github.com/Jeffail/gabs v1.4.0 github.com/pkg/errors v0.9.1 github.com/smartystreets/goconvey v1.7.2 diff --git a/go.sum b/go.sum index b28f983..fc1eeab 100644 --- a/go.sum +++ b/go.sum @@ -3,6 +3,10 @@ git.zhangdeman.cn/zhangdeman/easylock v0.0.0-20220627070212-c590a0a1c216/go.mod git.zhangdeman.cn/zhangdeman/util v0.0.0-20220626081130-cbac0b676fb8/go.mod h1:G2/OKMbEn89d+YUXQtv9Nlh0LGg14pOqDnbOgBTTRXY= git.zhangdeman.cn/zhangdeman/util v0.0.0-20230211164227-256094968151 h1:j537bRLQL1FlkdXTIaT9Ecjx5eogkPsGiTOWIEFQlc8= git.zhangdeman.cn/zhangdeman/util v0.0.0-20230211164227-256094968151/go.mod h1:SyRTkOz6gxUVn3S/Qtkf+rhKV0I1ym8lwsT8YjggYFs= +git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330065032-faba0a5a9ea1 h1:u2FdNfcGvRmlKpuPBk2qvYenkZjinHY2PLu5Wmhka8A= +git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330065032-faba0a5a9ea1/go.mod h1:SyRTkOz6gxUVn3S/Qtkf+rhKV0I1ym8lwsT8YjggYFs= +git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330082619-662152cb682d h1:kMQZmkYBceHM3O7wiCelSADjTyOF3EBxXTX8fgZA+6c= +git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330082619-662152cb682d/go.mod h1:qeVsrMae8ljqzcsmI+lWPU/4Rdjb9cOt4oaDUNEf1Ck= github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo= github.com/Jeffail/gabs v1.4.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc= github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ= diff --git a/tree/generate.go b/tree/generate.go index aa8b844..0aa7d02 100644 --- a/tree/generate.go +++ b/tree/generate.go @@ -9,6 +9,7 @@ package tree import ( "fmt" + "git.zhangdeman.cn/zhangdeman/util" "strings" "github.com/pkg/errors" @@ -27,6 +28,7 @@ func New(jsonData string) (*Generate, error) { } g.root = NewVirtualNode() g.currentNode = g.root + g.currentParentNode = g.root err := g.init() return g, err } @@ -86,7 +88,7 @@ func (g *Generate) init() error { fmt.Println(jsonKey, valueType, jsonValue, startIndex) // 创建节点, 并挂在到树上 var newNode *Node - if g.currentNode.ValueType == ValueTypeArray || g.currentNode.ValueType == ValueTypeMap { + if util.Array.In(g.currentNode.ValueType, []string{ValueTypeArray, ValueTypeMap}) >= 0 { newNode = NewNode(jsonKey, jsonValue, valueType, g.currentNode) g.currentParentNode = g.currentNode g.currentParentNode.SonNodeList = append(g.currentParentNode.SonNodeList, newNode) @@ -104,11 +106,11 @@ func (g *Generate) init() error { // // Date : 11:36 2023/3/29 func (g *Generate) getKey(startIndex int) (string, int, error) { - keyCharList := []string{} + keyCharList := make([]string, 0) hasStart := false for startIndex < len(g.jsonDataByte) { charStr := string(g.jsonDataByte[startIndex]) - if charStr == KeywordSpace { + if charStr == KeywordSpace && !hasStart { // 跳过空格 startIndex++ continue @@ -127,7 +129,12 @@ func (g *Generate) getKey(startIndex int) (string, int, error) { } if !hasStart { - if charStr == KeywordDoubleQuote || charStr == KeywordObjectStart || charStr == KeywordArrayStart || charStr == KeywordComma { + if util.Array.In(charStr, []string{ + KeywordDoubleQuote, + KeywordObjectStart, + KeywordArrayStart, + KeywordComma, + }) >= 0 { startIndex++ continue } @@ -252,18 +259,18 @@ func (g *Generate) getValue(startIndex int) (string, int, error) { isStart := false for startIndex < len(g.jsonDataByte) { str := string(g.jsonDataByte[startIndex]) - if str == KeywordSpace { + if str == KeywordSpace && !isStart { startIndex++ continue } if !isStart { - if str == KeywordArrayEnd || str == KeywordObjectEnd || str == KeywordComma { + if util.Array.In(str, []string{KeywordArrayEnd, KeywordObjectEnd, KeywordComma}) >= 0 { startIndex++ continue } } if isStart { - if str == KeywordDoubleQuote || str == KeywordArrayEnd || str == KeywordObjectEnd || str == KeywordComma { + if util.Array.In(str, []string{KeywordDoubleQuote, KeywordArrayEnd, KeywordObjectEnd, KeywordComma}) >= 0 { // 值的拼接已结束 startIndex++ break @@ -275,6 +282,7 @@ func (g *Generate) getValue(startIndex int) (string, int, error) { break } else { startIndex++ + isStart = true continue } } From aa290be33c0d2bf91e0667e5042bf7d6c43a0837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 30 Mar 2023 16:30:39 +0800 Subject: [PATCH 16/24] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E6=A0=88=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tree/node.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tree/node.go b/tree/node.go index 52f32a4..8b8885b 100644 --- a/tree/node.go +++ b/tree/node.go @@ -32,6 +32,7 @@ type Node struct { PreBrotherNode *Node // 前一个兄弟节点 LastBrotherNode *Node // 下一个兄弟节点 SonNodeList []*Node // 子节点列表 + ObjectStack []string // 对象信息堆栈, 利用栈的括号匹配, 判断某一个对象是否扫面完成 } // NewNode 创建新节点 @@ -54,6 +55,7 @@ func NewNode(key string, value string, valueType string, parentNode *Node) *Node PreBrotherNode: nil, LastBrotherNode: nil, SonNodeList: nil, + ObjectStack: make([]string, 0), } switch valueType { @@ -98,5 +100,9 @@ func NewNode(key string, value string, valueType string, parentNode *Node) *Node // // Date : 23:08 2023/3/28 func NewVirtualNode() *Node { - return &Node{IsVirtual: true, SonNodeList: make([]*Node, 0)} + return &Node{ + IsVirtual: true, + SonNodeList: make([]*Node, 0), + ObjectStack: make([]string, 0), + } } From 07f0e77b968fcf7c97d30f6ce19a487619f13bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 4 May 2023 17:41:55 +0800 Subject: [PATCH 17/24] =?UTF-8?q?=E4=BC=98=E5=8C=96get=20value=E6=8F=90?= =?UTF-8?q?=E5=8F=96=E7=9B=AE=E6=A0=87=E5=80=BC=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- const.go | 44 ++++++++++++++++++++++++++++++++++++++++++ filter.go | 57 ++++++++++++++++++++++++++----------------------------- 2 files changed, 71 insertions(+), 30 deletions(-) create mode 100644 const.go diff --git a/const.go b/const.go new file mode 100644 index 0000000..f104534 --- /dev/null +++ b/const.go @@ -0,0 +1,44 @@ +// Package filter ... +// +// Description : filter ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2023-05-04 17:29 +package filter + +const ( + DataTypeAny = "interface" + + DataTypeString = "string" + + DataTypeInt8 = "int8" + DataTypeInt16 = "int16" + DataTypeInt32 = "int32" + DataTypeInt64 = "int64" + DataTypeInt = "int" + + DataTypeUint8 = "uint8" + DataTypeUint16 = "uint16" + DataTypeUint32 = "uint32" + DataTypeUint64 = "uint64" + DataTypeUint = "uint" + + DataTypeBool = "bool" + + DataTypeNumber = "number" + + DataTypeFloat32 = "float32" + DataTypeFloat64 = "float64" + DataTypeDouble = "float64" + DataTypeFloat = "float" + + DataTypeIntSlice = "[]int" + DataTypeUntSlice = "[]uint" + DataTypeNumberSlice = "[]number" + DataTypeFloatSlice = "[]float" + DataTypeBoolSlice = "[]bool" + DataTypeAnySlice = "[]interface" + + DataTypeObject = "map[string]interface" +) diff --git a/filter.go b/filter.go index 1558979..7274184 100644 --- a/filter.go +++ b/filter.go @@ -64,17 +64,7 @@ func (f *filter) Deal() error { continue } sourceResult := gjson.Get(f.sourceData, rule.SourcePath) - var ( - sourceVal string - ) - - if !sourceResult.Exists() { - // 不存在, 使用默认值 - sourceVal = rule.DefaultValue - } else { - sourceVal = sourceResult.String() - } - if formatVal, err = f.getValue(rule.DataType, sourceVal); nil != err { + 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 { @@ -183,56 +173,63 @@ func (f *filter) Parse(receiver interface{}) error { // Author : go_developer@163.com<白茶清欢> // // Date : 12:25 2022/7/4 -func (f *filter) getValue(dataType string, defaultValue string) (interface{}, error) { +func (f *filter) getValue(dataType string, sourceValue gjson.Result, defaultValue string) (interface{}, error) { + sourceValueStr := defaultValue + if sourceValue.Exists() { + sourceValueStr = sourceValue.String() + } + switch dataType { - case "int8": + case DataTypeInt8: fallthrough - case "int16": + case DataTypeInt16: fallthrough - case "int32": + case DataTypeInt32: fallthrough - case "int64": + case DataTypeInt64: fallthrough - case "int": + case DataTypeInt: var ( err error val int64 ) - err = util.ConvertAssign(&val, defaultValue) + err = util.ConvertAssign(&val, sourceValueStr) return val, err - case "uint8": + case DataTypeUint8: fallthrough - case "uint16": + case DataTypeUint16: fallthrough - case "uint32": + case DataTypeUint32: fallthrough - case "uint64": + case DataTypeUint64: fallthrough - case "uint": + case DataTypeUint: var ( err error val uint64 ) - err = util.ConvertAssign(&val, defaultValue) + err = util.ConvertAssign(&val, sourceValueStr) return val, err - case "bool": + case DataTypeBool: var ( err error val bool ) - err = util.ConvertAssign(&val, defaultValue) + err = util.ConvertAssign(&val, sourceValueStr) return val, err - case "float32": + case DataTypeFloat32: fallthrough - case "float64": + case DataTypeFloat64: var ( err error val float64 ) - err = util.ConvertAssign(&val, defaultValue) + err = util.ConvertAssign(&val, sourceValueStr) return val, err - case "string": + case DataTypeString: return defaultValue, nil + case DataTypeAny: + return sourceValue.Value(), nil default: return nil, errors.New(dataType + " is not support!") } From 01b6e1abe8c427d7255a02ea6e31b0c1fe6b6dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 4 May 2023 17:50:45 +0800 Subject: [PATCH 18/24] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- filter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filter.go b/filter.go index 7274184..354f819 100644 --- a/filter.go +++ b/filter.go @@ -227,7 +227,7 @@ func (f *filter) getValue(dataType string, sourceValue gjson.Result, defaultValu err = util.ConvertAssign(&val, sourceValueStr) return val, err case DataTypeString: - return defaultValue, nil + return sourceValueStr, nil case DataTypeAny: return sourceValue.Value(), nil default: From 6130732a90696732b55afca2a6dab990a6957991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 4 May 2023 18:04:47 +0800 Subject: [PATCH 19/24] =?UTF-8?q?=E5=A2=9E=E5=8A=A0number=20/=20double?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- const.go | 2 +- filter.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/const.go b/const.go index f104534..6474405 100644 --- a/const.go +++ b/const.go @@ -30,7 +30,7 @@ const ( DataTypeFloat32 = "float32" DataTypeFloat64 = "float64" - DataTypeDouble = "float64" + DataTypeDouble = "double" DataTypeFloat = "float" DataTypeIntSlice = "[]int" diff --git a/filter.go b/filter.go index 354f819..426cad0 100644 --- a/filter.go +++ b/filter.go @@ -220,6 +220,12 @@ func (f *filter) getValue(dataType string, sourceValue gjson.Result, defaultValu case DataTypeFloat32: fallthrough case DataTypeFloat64: + fallthrough + case DataTypeFloat: + fallthrough + case DataTypeDouble: + fallthrough + case DataTypeNumber: var ( err error val float64 From 920b2c45b984225a7460d17a0de24ff2b1b5adc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 4 May 2023 18:18:03 +0800 Subject: [PATCH 20/24] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9[]interface?= =?UTF-8?q?=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- filter.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/filter.go b/filter.go index 426cad0..61d1b0c 100644 --- a/filter.go +++ b/filter.go @@ -176,7 +176,10 @@ func (f *filter) Parse(receiver interface{}) error { func (f *filter) getValue(dataType string, sourceValue gjson.Result, defaultValue string) (interface{}, error) { sourceValueStr := defaultValue if sourceValue.Exists() { - sourceValueStr = sourceValue.String() + str := sourceValue.String() + if len(str) > 0 { + sourceValueStr = str + } } switch dataType { @@ -236,6 +239,15 @@ func (f *filter) getValue(dataType string, sourceValue gjson.Result, defaultValu return sourceValueStr, nil case DataTypeAny: return sourceValue.Value(), nil + case DataTypeAnySlice: + // 任意类型的list + var ( + result []interface{} + ) + if err := util.JSON.UnmarshalWithNumber([]byte(sourceValueStr), &result); nil != err { + return nil, err + } + return result, nil default: return nil, errors.New(dataType + " is not support!") } From 214feb35f707e534939271a5c8c1236152c6b79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 4 May 2023 18:22:54 +0800 Subject: [PATCH 21/24] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E7=9A=84=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- filter.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/filter.go b/filter.go index 61d1b0c..1194985 100644 --- a/filter.go +++ b/filter.go @@ -248,6 +248,15 @@ func (f *filter) getValue(dataType string, sourceValue gjson.Result, defaultValu return nil, err } return result, nil + case DataTypeObject: + // object + var ( + result map[string]interface{} + ) + if err := util.JSON.UnmarshalWithNumber([]byte(sourceValueStr), &result); nil != err { + return nil, err + } + return result, nil default: return nil, errors.New(dataType + " is not support!") } From b8c7725c0836e68eb3c6df698ee859bb04273b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 5 May 2023 11:42:09 +0800 Subject: [PATCH 22/24] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- filter.go | 52 ++++++++++++++++------------------------------------ go.mod | 4 +++- go.sum | 6 ++++++ 3 files changed, 25 insertions(+), 37 deletions(-) diff --git a/filter.go b/filter.go index 1194985..3c2b6a8 100644 --- a/filter.go +++ b/filter.go @@ -184,57 +184,37 @@ func (f *filter) getValue(dataType string, sourceValue gjson.Result, defaultValu switch dataType { case DataTypeInt8: - fallthrough + return util.StringConvert.ToInt8(sourceValueStr) case DataTypeInt16: - fallthrough + return util.StringConvert.ToInt16(sourceValueStr) case DataTypeInt32: - fallthrough + return util.StringConvert.ToInt32(sourceValueStr) case DataTypeInt64: - fallthrough + return util.StringConvert.ToInt64(sourceValueStr) case DataTypeInt: - var ( - err error - val int64 - ) - err = util.ConvertAssign(&val, sourceValueStr) - return val, err + return util.StringConvert.ToInt(sourceValueStr) case DataTypeUint8: - fallthrough + return util.StringConvert.ToUint8(sourceValueStr) case DataTypeUint16: - fallthrough + return util.StringConvert.ToUint16(sourceValueStr) case DataTypeUint32: - fallthrough + return util.StringConvert.ToUint32(sourceValueStr) case DataTypeUint64: - fallthrough + return util.StringConvert.ToUint64(sourceValueStr) case DataTypeUint: - var ( - err error - val uint64 - ) - err = util.ConvertAssign(&val, sourceValueStr) - return val, err + return util.StringConvert.ToUint(sourceValueStr) case DataTypeBool: - var ( - err error - val bool - ) - err = util.ConvertAssign(&val, sourceValueStr) - return val, err + return util.StringConvert.ToBool(sourceValueStr) case DataTypeFloat32: - fallthrough + return util.StringConvert.ToFloat32(sourceValueStr) case DataTypeFloat64: - fallthrough + return util.StringConvert.ToFloat64(sourceValueStr) case DataTypeFloat: - fallthrough + return util.StringConvert.ToFloat64(sourceValueStr) case DataTypeDouble: - fallthrough + return util.StringConvert.ToDouble(sourceValueStr) case DataTypeNumber: - var ( - err error - val float64 - ) - err = util.ConvertAssign(&val, sourceValueStr) - return val, err + return util.StringConvert.ToNumber(sourceValueStr) case DataTypeString: return sourceValueStr, nil case DataTypeAny: diff --git a/go.mod b/go.mod index eeb28e4..c3b6d01 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( git.zhangdeman.cn/zhangdeman/easylock v0.0.0-20220627070212-c590a0a1c216 - git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330082619-662152cb682d + git.zhangdeman.cn/zhangdeman/util v0.0.0-20230505025924-96532aff0019 github.com/Jeffail/gabs v1.4.0 github.com/pkg/errors v0.9.1 github.com/smartystreets/goconvey v1.7.2 @@ -19,6 +19,8 @@ require ( github.com/go-ini/ini v1.67.0 // indirect github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect github.com/jtolds/gls v4.20.0+incompatible // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect + github.com/mssola/user_agent v0.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/smartystreets/assertions v1.2.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect diff --git a/go.sum b/go.sum index fc1eeab..571448e 100644 --- a/go.sum +++ b/go.sum @@ -7,6 +7,8 @@ git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330065032-faba0a5a9ea1 h1:u2FdNfcG git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330065032-faba0a5a9ea1/go.mod h1:SyRTkOz6gxUVn3S/Qtkf+rhKV0I1ym8lwsT8YjggYFs= git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330082619-662152cb682d h1:kMQZmkYBceHM3O7wiCelSADjTyOF3EBxXTX8fgZA+6c= git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330082619-662152cb682d/go.mod h1:qeVsrMae8ljqzcsmI+lWPU/4Rdjb9cOt4oaDUNEf1Ck= +git.zhangdeman.cn/zhangdeman/util v0.0.0-20230505025924-96532aff0019 h1:eJ/9rEj2iI8P9I1DfCmMUvsV+n2EiAWCXnI9yVVDHO0= +git.zhangdeman.cn/zhangdeman/util v0.0.0-20230505025924-96532aff0019/go.mod h1:z2bP5LIwRVpWSQV0/a3WIFaoarJUP8kA/0Clv0bP+8I= github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo= github.com/Jeffail/gabs v1.4.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc= github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ= @@ -22,6 +24,10 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGa github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mssola/user_agent v0.6.0 h1:uwPR4rtWlCHRFyyP9u2KOV0u8iQXmS7Z7feTrstQwk4= +github.com/mssola/user_agent v0.6.0/go.mod h1:TTPno8LPY3wAIEKRpAtkdMT0f8SE24pLRGPahjCH4uw= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= From 3487a87104533e0639094cc4f8fa5fc4a0e39a61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 5 May 2023 15:03:49 +0800 Subject: [PATCH 23/24] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- const.go | 44 -------------------------- filter.go | 93 ++++++++++++++++++++++++------------------------------- go.mod | 1 + go.sum | 4 +++ 4 files changed, 46 insertions(+), 96 deletions(-) delete mode 100644 const.go diff --git a/const.go b/const.go deleted file mode 100644 index 6474405..0000000 --- a/const.go +++ /dev/null @@ -1,44 +0,0 @@ -// Package filter ... -// -// Description : filter ... -// -// Author : go_developer@163.com<白茶清欢> -// -// Date : 2023-05-04 17:29 -package filter - -const ( - DataTypeAny = "interface" - - DataTypeString = "string" - - DataTypeInt8 = "int8" - DataTypeInt16 = "int16" - DataTypeInt32 = "int32" - DataTypeInt64 = "int64" - DataTypeInt = "int" - - DataTypeUint8 = "uint8" - DataTypeUint16 = "uint16" - DataTypeUint32 = "uint32" - DataTypeUint64 = "uint64" - DataTypeUint = "uint" - - DataTypeBool = "bool" - - DataTypeNumber = "number" - - DataTypeFloat32 = "float32" - DataTypeFloat64 = "float64" - DataTypeDouble = "double" - DataTypeFloat = "float" - - DataTypeIntSlice = "[]int" - DataTypeUntSlice = "[]uint" - DataTypeNumberSlice = "[]number" - DataTypeFloatSlice = "[]float" - DataTypeBoolSlice = "[]bool" - DataTypeAnySlice = "[]interface" - - DataTypeObject = "map[string]interface" -) diff --git a/filter.go b/filter.go index 3c2b6a8..8ca7dfe 100644 --- a/filter.go +++ b/filter.go @@ -10,14 +10,13 @@ package filter import ( "encoding/json" "fmt" + "git.zhangdeman.cn/zhangdeman/wrapper" "strings" "github.com/tidwall/gjson" "github.com/tidwall/sjson" "errors" - - "git.zhangdeman.cn/zhangdeman/util" ) // NewFilter 过滤器实例 @@ -182,61 +181,51 @@ func (f *filter) getValue(dataType string, sourceValue gjson.Result, defaultValu } } + strVal := wrapper.String(sourceValueStr) + switch dataType { - case DataTypeInt8: - return util.StringConvert.ToInt8(sourceValueStr) - case DataTypeInt16: - return util.StringConvert.ToInt16(sourceValueStr) - case DataTypeInt32: - return util.StringConvert.ToInt32(sourceValueStr) - case DataTypeInt64: - return util.StringConvert.ToInt64(sourceValueStr) - case DataTypeInt: - return util.StringConvert.ToInt(sourceValueStr) - case DataTypeUint8: - return util.StringConvert.ToUint8(sourceValueStr) - case DataTypeUint16: - return util.StringConvert.ToUint16(sourceValueStr) - case DataTypeUint32: - return util.StringConvert.ToUint32(sourceValueStr) - case DataTypeUint64: - return util.StringConvert.ToUint64(sourceValueStr) - case DataTypeUint: - return util.StringConvert.ToUint(sourceValueStr) - case DataTypeBool: - return util.StringConvert.ToBool(sourceValueStr) - case DataTypeFloat32: - return util.StringConvert.ToFloat32(sourceValueStr) - case DataTypeFloat64: - return util.StringConvert.ToFloat64(sourceValueStr) - case DataTypeFloat: - return util.StringConvert.ToFloat64(sourceValueStr) - case DataTypeDouble: - return util.StringConvert.ToDouble(sourceValueStr) - case DataTypeNumber: - return util.StringConvert.ToNumber(sourceValueStr) - case DataTypeString: + case wrapper.DataTypeInt8: + return strVal.ToInt8() + case wrapper.DataTypeInt16: + return strVal.ToInt16() + case wrapper.DataTypeInt32: + return strVal.ToInt32() + case wrapper.DataTypeInt64: + return strVal.ToInt64() + case wrapper.DataTypeInt: + return strVal.ToInt() + case wrapper.DataTypeUint8: + return strVal.ToUint8() + case wrapper.DataTypeUint16: + return strVal.ToUint16() + case wrapper.DataTypeUint32: + return strVal.ToUint32() + case wrapper.DataTypeUint64: + return strVal.ToUint64() + case wrapper.DataTypeUint: + return strVal.ToUint() + case wrapper.DataTypeBool: + return strVal.ToBool() + case wrapper.DataTypeFloat32: + return strVal.ToFloat64() + case wrapper.DataTypeFloat64: + fallthrough + case wrapper.DataTypeFloat: + fallthrough + case wrapper.DataTypeDouble: + return strVal.ToFloat64() + case wrapper.DataTypeNumber: + return strVal.ToNumber() + case wrapper.DataTypeString: return sourceValueStr, nil - case DataTypeAny: + case wrapper.DataTypeAny: return sourceValue.Value(), nil - case DataTypeAnySlice: + case wrapper.DataTypeAnySlice: // 任意类型的list - var ( - result []interface{} - ) - if err := util.JSON.UnmarshalWithNumber([]byte(sourceValueStr), &result); nil != err { - return nil, err - } - return result, nil - case DataTypeObject: + return strVal.ToAnySlice() + case wrapper.DataTypeObject: // object - var ( - result map[string]interface{} - ) - if err := util.JSON.UnmarshalWithNumber([]byte(sourceValueStr), &result); nil != err { - return nil, err - } - return result, nil + return strVal.ToObject() default: return nil, errors.New(dataType + " is not support!") } diff --git a/go.mod b/go.mod index c3b6d01..66bca94 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( ) require ( + git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20230505070245-b182b21e039b // indirect github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect diff --git a/go.sum b/go.sum index 571448e..946bac3 100644 --- a/go.sum +++ b/go.sum @@ -9,6 +9,10 @@ git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330082619-662152cb682d h1:kMQZmkYB git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330082619-662152cb682d/go.mod h1:qeVsrMae8ljqzcsmI+lWPU/4Rdjb9cOt4oaDUNEf1Ck= git.zhangdeman.cn/zhangdeman/util v0.0.0-20230505025924-96532aff0019 h1:eJ/9rEj2iI8P9I1DfCmMUvsV+n2EiAWCXnI9yVVDHO0= git.zhangdeman.cn/zhangdeman/util v0.0.0-20230505025924-96532aff0019/go.mod h1:z2bP5LIwRVpWSQV0/a3WIFaoarJUP8kA/0Clv0bP+8I= +git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20230505064614-5e785171ed67 h1:DH9K3fNddpFxRGLkcLP5MHsAQVinpWpmGzbVBf8yrKM= +git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20230505064614-5e785171ed67/go.mod h1:2jc48WuVoHxZjkvlBewzp+ey8khP1K4OOcibVD1yL2k= +git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20230505070245-b182b21e039b h1:ZwAA10/+v3FFAq5/EzjXdXDodmKppXb5gBkCcgaYVBo= +git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20230505070245-b182b21e039b/go.mod h1:2jc48WuVoHxZjkvlBewzp+ey8khP1K4OOcibVD1yL2k= github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo= github.com/Jeffail/gabs v1.4.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc= github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ= From eb5432cd773ccfed125831a7786dfac6338f9841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 5 May 2023 16:09:10 +0800 Subject: [PATCH 24/24] update go mod --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 66bca94..b81a9f6 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( ) require ( - git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20230505070245-b182b21e039b // indirect + git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20230505080742-fa2f27724d76 // indirect github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect diff --git a/go.sum b/go.sum index 946bac3..dfa91ed 100644 --- a/go.sum +++ b/go.sum @@ -13,6 +13,8 @@ git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20230505064614-5e785171ed67 h1:DH9K3 git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20230505064614-5e785171ed67/go.mod h1:2jc48WuVoHxZjkvlBewzp+ey8khP1K4OOcibVD1yL2k= git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20230505070245-b182b21e039b h1:ZwAA10/+v3FFAq5/EzjXdXDodmKppXb5gBkCcgaYVBo= git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20230505070245-b182b21e039b/go.mod h1:2jc48WuVoHxZjkvlBewzp+ey8khP1K4OOcibVD1yL2k= +git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20230505080742-fa2f27724d76 h1:IEixZNZY3/nqb5v9PzzgSeXLPp0U7wRaxrM+ZaSh+j0= +git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20230505080742-fa2f27724d76/go.mod h1:2jc48WuVoHxZjkvlBewzp+ey8khP1K4OOcibVD1yL2k= github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo= github.com/Jeffail/gabs v1.4.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc= github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ=