You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
860 B
55 lines
860 B
1 month ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"github.com/deatil/go-array/array"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
|
||
|
arrData := map[string]any{
|
||
|
"a": 123,
|
||
|
"b": map[string]any{
|
||
|
"c": "ccc",
|
||
|
"d": map[string]any{
|
||
|
"e": "eee",
|
||
|
"f": map[string]any{
|
||
|
"g": "ggg",
|
||
|
},
|
||
|
},
|
||
|
"dd": []any{
|
||
|
"ccccc",
|
||
|
"ddddd",
|
||
|
"fffff",
|
||
|
},
|
||
|
"ff": map[any]any{
|
||
|
111: "fccccc",
|
||
|
222: "fddddd",
|
||
|
333: "dfffff",
|
||
|
},
|
||
|
"hh": map[int]any{
|
||
|
1115: "hccccc",
|
||
|
2225: "hddddd",
|
||
|
3335: map[any]string{
|
||
|
"qq1": "qq1ccccc",
|
||
|
"qq2": "qq2ddddd",
|
||
|
"qq3": "qq3fffff",
|
||
|
},
|
||
|
},
|
||
|
"kJh21ay": map[string]any{
|
||
|
"Hjk2": "fccDcc",
|
||
|
"23rt": "^hgcF5c",
|
||
|
},
|
||
|
},
|
||
|
}
|
||
|
|
||
|
fmt.Println(array.Get(arrData, "b.d.e"))
|
||
|
// output: eee
|
||
|
|
||
|
fmt.Println(array.Get(arrData, "b.dd.1"))
|
||
|
// output: ddddd
|
||
|
|
||
|
fmt.Println(array.Get(arrData, "b.hh.3335.qq2"))
|
||
|
// output: qq2ddddd
|
||
|
}
|