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 +}