Skip to content

Instantly share code, notes, and snippets.

@douglarek
Created March 26, 2018 14:02
Show Gist options
  • Save douglarek/3073a8a6b86ef51e9e1b712e3cb3d71b to your computer and use it in GitHub Desktop.
Save douglarek/3073a8a6b86ef51e9e1b712e3cb3d71b to your computer and use it in GitHub Desktop.
package main
import "encoding/json"
// jsonText comes from http://json.org/example.html
var jsonText = []byte(`
{
... // 此处省略, 同上
}`)
type glossarySectional struct {
Glossary struct {
Title string `json:"title"`
GlossDiv struct {
Title string `json:"title"`
GlossList json.RawMessage `json:"GlossList"` // diff: delay JSON decoding
} `json:"GlossDiv"`
} `json:"glossary"`
}
func main() {
var g glossarySectional
json.Unmarshal(jsonText, &g)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment