优化Result

This commit is contained in:
白茶清欢 2024-12-04 20:15:42 +08:00
parent ee2326af91
commit 355144b623
2 changed files with 40 additions and 1 deletions

View File

@ -240,5 +240,5 @@ func Result(gjsonResult gjson.Result) gjson.Result {
if IsArray(gjsonResult) {
return Array(gjsonResult)
}
return gjsonResult
return Object(gjsonResult)
}

39
sjson_hack/set.go Normal file
View File

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