Last active
December 21, 2019 14:11
-
-
Save gsscoder/ad8f271e218dbfae1d825eadc73662a1 to your computer and use it in GitHub Desktop.
Go program that parses JSON with tidwall/gjson
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "github.com/tidwall/gjson" | |
| ) | |
| var data = ` | |
| { | |
| "keys": { | |
| "key0": {"this": 10, "that": "hello"}, | |
| "key1": {"this": 11, "that": "world"} | |
| } | |
| }` | |
| func main() { | |
| result := gjson.Get(data, "keys") | |
| result.ForEach(func(key, value gjson.Result) bool { | |
| fmt.Printf("%s %s", key.String(), value.String()) | |
| return true // keep iterating | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment