examples/read-raw-bytes/main.go
raw| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | |
| 6 | "github.com/knadh/koanf/parsers/json" |
| 7 | "github.com/knadh/koanf/providers/rawbytes" |
| 8 | "github.com/knadh/koanf/v2" |
| 9 | ) |
| 10 | |
| 11 | // Global koanf instance. Use . as the key path delimiter. This can be / or anything. |
| 12 | var k = koanf.New(".") |
| 13 | |
| 14 | func main() { |
| 15 | b := []byte(`{"type": "rawbytes", "parent1": {"child1": {"type": "rawbytes"}}}`) |
| 16 | k.Load(rawbytes.Provider(b), json.Parser()) |
| 17 | fmt.Println("type is = ", k.String("parent1.child1.type")) |
| 18 | } |