Skip to content

Instantly share code, notes, and snippets.

@agocs
Last active April 25, 2016 04:45
Show Gist options
  • Save agocs/60cc9fd91a73d343bfcafb69282da5ce to your computer and use it in GitHub Desktop.
Save agocs/60cc9fd91a73d343bfcafb69282da5ce to your computer and use it in GitHub Desktop.
package main
import (
"encoding/json"
"io"
)
type Hacker struct {
Name string
Plan string
}
// decodeHacker will return a Hacker when presented with
// JSON data that looks like
// `{"Name": "Testy McTesterson", "Plan": "Full Member"}`
func decodeHacker(someJson io.Reader) Hacker {
var someHacker Hacker
decoder := json.NewDecoder(someJson)
decoder.Decode(&someHacker)
return someHacker
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment