Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1391 from weaveworks/1390-use-number
Browse files Browse the repository at this point in the history
Stop marshalling numbers as floats

Fixes #1390.
  • Loading branch information
rade committed Sep 4, 2015
2 parents 99b482b + c50968a commit f782fb5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions proxy/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ func unmarshalRequestBody(r *http.Request, target interface{}) error {
}
r.Body = ioutil.NopCloser(bytes.NewReader(body))

return json.Unmarshal(body, &target)
d := json.NewDecoder(bytes.NewReader(body))
d.UseNumber() // don't want large numbers in scientific format
return d.Decode(&target)
}

func marshalRequestBody(r *http.Request, body interface{}) error {
Expand All @@ -73,7 +75,9 @@ func unmarshalResponseBody(r *http.Response, target interface{}) error {
}
r.Body = ioutil.NopCloser(bytes.NewReader(body))

return json.Unmarshal(body, &target)
d := json.NewDecoder(bytes.NewReader(body))
d.UseNumber() // don't want large numbers in scientific format
return d.Decode(&target)
}

func marshalResponseBody(r *http.Response, body interface{}) error {
Expand Down

0 comments on commit f782fb5

Please sign in to comment.