Last active
April 25, 2016 04:45
-
-
Save agocs/60cc9fd91a73d343bfcafb69282da5ce to your computer and use it in GitHub Desktop.
This file contains 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" | |
"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