feat: ipdate op_string
This commit is contained in:
@ -9,11 +9,12 @@ package sjson_hack
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.zhangdeman.cn/zhangdeman/json_filter/gjson_hack"
|
||||
"git.zhangdeman.cn/zhangdeman/wrapper"
|
||||
"github.com/tidwall/sjson"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/json_filter/gjson_hack"
|
||||
"git.zhangdeman.cn/zhangdeman/wrapper/op_string"
|
||||
"github.com/tidwall/sjson"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -21,14 +22,10 @@ var (
|
||||
)
|
||||
|
||||
// Set 设置路径的值
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 11:36 2024/12/3
|
||||
func Set(jsonRes string, path string, value any) (string, error) {
|
||||
var (
|
||||
err error
|
||||
res string = jsonRes
|
||||
res = jsonRes
|
||||
)
|
||||
|
||||
// 包含特殊字符串, 匹配出特殊字符串
|
||||
@ -36,7 +33,7 @@ func Set(jsonRes string, path string, value any) (string, error) {
|
||||
specialKeyTale := map[string]string{}
|
||||
for _, item := range specialKeyList {
|
||||
// 替换掉占位字符串
|
||||
specialKeyTale[item] = wrapper.StringFromRandom(64, "").Md5().Value
|
||||
specialKeyTale[item] = op_string.Md5(op_string.Random(64, "")).Value
|
||||
path = strings.ReplaceAll(path, item, specialKeyTale[item])
|
||||
}
|
||||
|
||||
@ -53,10 +50,6 @@ func Set(jsonRes string, path string, value any) (string, error) {
|
||||
}
|
||||
|
||||
// getSpecialKeyList 获取特殊key列表
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 17:35 2024/12/5
|
||||
func getSpecialKeyList(path string) []string {
|
||||
matchList := reg.FindAllString(path, -1)
|
||||
if len(matchList) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user