SHARE
TWEET

Untitled

a guest Mar 21st, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const jsonStream = `{"Name": "Ed", "Text": "Knock knock."}`
  2. type Message struct {
  3. Ā Name, Text string
  4. }
  5. var m Message
  6. decĀ := json.NewDecoder(strings.NewReader(jsonStream))
  7. errĀ := dec.Decode(&m)
  8. if errĀ != nil && errĀ != io.EOF {
  9.   // handle a possible error
  10. }
  11. fmt.Println(m.Name, m.Text)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top