From 355144b623ce6f7c52a32642e2012f7233c67f82 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, 4 Dec 2024 20:15:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Result?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gjson_hack/path.go | 2 +- sjson_hack/set.go | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 sjson_hack/set.go diff --git a/gjson_hack/path.go b/gjson_hack/path.go index 2e7995a..1814ab8 100644 --- a/gjson_hack/path.go +++ b/gjson_hack/path.go @@ -240,5 +240,5 @@ func Result(gjsonResult gjson.Result) gjson.Result { if IsArray(gjsonResult) { return Array(gjsonResult) } - return gjsonResult + return Object(gjsonResult) } diff --git a/sjson_hack/set.go b/sjson_hack/set.go new file mode 100644 index 0000000..f1075a2 --- /dev/null +++ b/sjson_hack/set.go @@ -0,0 +1,39 @@ +// Package sjson_hack ... +// +// Description : sjson_hack ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2024-12-03 11:36 +package sjson_hack + +import "strings" + +// Set 设置路径的值 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 11:36 2024/12/3 +func Set(jsonRes string, path string, value any) (string, error) { + if !isPathHasSpecialChar(path) { + // 不包含特殊字符 + } + return "", nil +} + +// isPathHasSpecialChar 判断路径中是否包含特殊字符 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 11:38 2024/12/3 +func isPathHasSpecialChar(path string) bool { + specialCharList := []string{ + ".", + } + for _, itemChar := range specialCharList { + if strings.Contains(path, itemChar) { + return true + } + } + return false +}