gjson读取参数支持key名称中包含.
This commit is contained in:
@ -179,3 +179,20 @@ func TestExpandArrayPath(t *testing.T) {
|
||||
}
|
||||
fmt.Println(res)
|
||||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
mapData := map[string]any{
|
||||
"person.name": "test",
|
||||
"test": map[string]any{
|
||||
"a.b": "c",
|
||||
"d.e": map[string]any{
|
||||
"e.f": "g",
|
||||
},
|
||||
},
|
||||
}
|
||||
byteData, _ := json.Marshal(mapData)
|
||||
gjsonResult := gjson.ParseBytes(byteData)
|
||||
fmt.Println(Get(gjsonResult, "{{#person.name#}}").String())
|
||||
fmt.Println(Get(gjsonResult, "test.{{#a.b#}}").String())
|
||||
fmt.Println(Get(gjsonResult, "test.{{#d.e#}}.{{#e.f#}}").String())
|
||||
}
|
||||
|
Reference in New Issue
Block a user