()
| 81 | } |
| 82 | |
| 83 | func ExampleValue_Get() { |
| 84 | s := `{"foo":[{"bar":{"baz":123,"x":"434"},"y":[]},[null, false]],"qwe":true}` |
| 85 | var p fastjson.Parser |
| 86 | v, err := p.Parse(s) |
| 87 | if err != nil { |
| 88 | log.Fatalf("cannot parse json: %s", err) |
| 89 | } |
| 90 | |
| 91 | vv := v.Get("foo", "0", "bar", "x") |
| 92 | fmt.Printf("foo[0].bar.x=%s\n", vv.GetStringBytes()) |
| 93 | |
| 94 | vv = v.Get("qwe") |
| 95 | fmt.Printf("qwe=%v\n", vv.GetBool()) |
| 96 | |
| 97 | vv = v.Get("foo", "1") |
| 98 | fmt.Printf("foo[1]=%s\n", vv) |
| 99 | |
| 100 | vv = v.Get("foo").Get("1").Get("1") |
| 101 | fmt.Printf("foo[1][1]=%s\n", vv) |
| 102 | |
| 103 | // non-existing key |
| 104 | vv = v.Get("foo").Get("bar").Get("baz", "1234") |
| 105 | fmt.Printf("foo.bar.baz[1234]=%v\n", vv) |
| 106 | |
| 107 | // Output: |
| 108 | // foo[0].bar.x=434 |
| 109 | // qwe=true |
| 110 | // foo[1]=[null,false] |
| 111 | // foo[1][1]=false |
| 112 | // foo.bar.baz[1234]=<nil> |
| 113 | } |
| 114 | |
| 115 | func ExampleValue_Type() { |
| 116 | s := `{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…