Created
March 26, 2018 13:31
-
-
Save douglarek/1283565bf479fc870bce4774b2b12be8 to your computer and use it in GitHub Desktop.
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 "encoding/json" | |
// jsonText comes from http://json.org/example.html | |
var jsonText = []byte(` | |
{ | |
"glossary":{ | |
"title":"example glossary", | |
"GlossDiv":{ | |
"title":"S", | |
"GlossList":{ | |
"GlossEntry":{ | |
"ID":"SGML", | |
"SortAs":"SGML", | |
"GlossTerm":"Standard Generalized Markup Language", | |
"Acronym":"SGML", | |
"Abbrev":"ISO 8879:1986", | |
"GlossDef":{ | |
"para":"A meta-markup language, used to create markup languages such as DocBook.", | |
"GlossSeeAlso":[ | |
"GML", | |
"XML" | |
] | |
}, | |
"GlossSee":"markup" | |
} | |
} | |
} | |
} | |
}`) | |
type glossary struct { | |
Glossary struct { | |
Title string `json:"title"` | |
GlossDiv struct { | |
Title string `json:"title"` | |
GlossList struct { | |
GlossEntry struct { | |
ID string `json:"ID"` | |
SortAs string `json:"SortAs"` | |
GlossTerm string `json:"GlossTerm"` | |
Acronym string `json:"Acronym"` | |
Abbrev string `json:"Abbrev"` | |
GlossDef struct { | |
Para string `json:"para"` | |
GlossSeeAlso []string `json:"GlossSeeAlso"` | |
} `json:"GlossDef"` | |
GlossSee string `json:"GlossSee"` | |
} `json:"GlossEntry"` | |
} `json:"GlossList"` | |
} `json:"GlossDiv"` | |
} `json:"glossary"` | |
} | |
func main() { | |
var g glossary | |
json.Unmarshal(jsonText, &g) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment