gjson+sjson hack升级 #8

Merged
zhangdeman merged 6 commits from feature/sjson_hack into master 2024-12-05 18:50:07 +08:00
2 changed files with 40 additions and 1 deletions
Showing only changes of commit 355144b623 - Show all commits

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
}