数组按照真实层级展开后, 自动生成新的映射路径

This commit is contained in:
2024-11-30 17:07:50 +08:00
parent cb23772664
commit 0ca808c4fb
3 changed files with 29 additions and 7 deletions

View File

@ -10,8 +10,9 @@ package gjson_hack
import (
"encoding/json"
"fmt"
"github.com/tidwall/gjson"
"testing"
"github.com/tidwall/gjson"
)
func TestPath(t *testing.T) {
@ -163,7 +164,10 @@ func TestExpandArrayPath(t *testing.T) {
byteData, _ := json.Marshal(mapData)
jsonStr := string(byteData)
// fmt.Println(jsonStr)
var pathExpendRes = &ExpendArrayResult{PathList: nil}
ExpandArrayPath(jsonStr, "user_list.{{idx}}.{{idx}}.age", pathExpendRes)
var pathExpendRes = &ExpendArrayResult{
PathList: nil,
PathMap: nil,
}
ExpandArrayPath(jsonStr, "user_list.{{idx}}.{{idx}}.age", "", pathExpendRes)
fmt.Println(pathExpendRes)
}