Created
July 23, 2014 16:01
-
-
Save jmoiron/1fd73d3362fb31113ded 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
func LoadGzippedJSON(r io.Reader, v interface{}) error { | |
data, err := ioutil.ReadAll(r) | |
if err != nil { | |
return err | |
} | |
// oh wait, we need a Reader again.. | |
raw := bytes.NewBuffer(data) | |
unz, err := gzip.NewReader(raw) | |
if err != nil { | |
return err | |
} | |
buf, err := ioutil.ReadAll(unz) | |
if err != nil { | |
return err | |
} | |
return json.Unmarshal(buf, &v) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment