Last active
December 21, 2019 13:37
-
-
Save gsscoder/df9f086f21e242787b407cd8e055e193 to your computer and use it in GitHub Desktop.
Go program that parses JSON with buger/jsonparser
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/buger/jsonparser" | |
| ) | |
| var data = []byte(` | |
| { | |
| "keys": { | |
| "key0": {"this": 10, "that": "hello"}, | |
| "key1": {"this": 11, "that": "world"} | |
| } | |
| }`) | |
| func main() { | |
| jsonparser.ObjectEach(data, func(key []byte, value []byte, dataType jsonparser.ValueType, offset int) error { | |
| fmt.Printf("Key: '%s'\n Value: '%s'\n Type: %s\n", string(key), string(value), dataType) | |
| return nil | |
| }, "keys", "key0") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment