From f862eada83b6437a6d339df1ab8e92d236932a4c Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Sat, 28 Mar 2015 18:30:24 +1100 Subject: [PATCH] Made use of common JSON/Encoding function. --- bitfinexhttp.go | 5 ++--- bitstamphttp.go | 3 +-- btcchinahttp.go | 3 +-- currency.go | 3 +-- itbithttp.go | 3 +-- kraken.go | 3 +-- 6 files changed, 7 insertions(+), 13 deletions(-) diff --git a/bitfinexhttp.go b/bitfinexhttp.go index 833a10a3..852924af 100644 --- a/bitfinexhttp.go +++ b/bitfinexhttp.go @@ -3,7 +3,6 @@ package main import ( "fmt" "log" - "encoding/json" "errors" "strings" "strconv" @@ -273,7 +272,7 @@ func (b *Bitfinex) SendAuthenticatedHTTPRequest(method, path string, params map[ } } - PayloadJson, err := json.Marshal(request) + PayloadJson, err := JSONEncode(request) if err != nil { return errors.New("SendAuthenticatedHTTPRequest: Unable to JSON request") @@ -296,7 +295,7 @@ func (b *Bitfinex) SendAuthenticatedHTTPRequest(method, path string, params map[ log.Printf("Recieved raw: \n%s\n", resp) } - err = json.Unmarshal([]byte(resp), &result) + err = JSONDecode([]byte(resp), &result) if err != nil { return errors.New("Unable to JSON Unmarshal response.") diff --git a/bitstamphttp.go b/bitstamphttp.go index e9808507..c55ff266 100644 --- a/bitstamphttp.go +++ b/bitstamphttp.go @@ -3,7 +3,6 @@ package main import ( "net/url" "log" - "encoding/json" "strings" "strconv" "errors" @@ -313,7 +312,7 @@ func (b *Bitstamp) SendAuthenticatedHTTPRequest(path string, values url.Values, log.Printf("Recieved raw: %s\n", resp) } - err = json.Unmarshal([]byte(resp), &result) + err = JSONDecode([]byte(resp), &result) if err != nil { return errors.New("Unable to JSON Unmarshal response.") diff --git a/btcchinahttp.go b/btcchinahttp.go index 463bd667..5ecd5edb 100644 --- a/btcchinahttp.go +++ b/btcchinahttp.go @@ -3,7 +3,6 @@ package main import ( "net/url" "strconv" - "encoding/json" "errors" "strings" "time" @@ -711,7 +710,7 @@ func (b *BTCChina) SendAuthenticatedHTTPRequest(method string, params []interfac postData["method"] = method postData["params"] = params postData["id"] = 1 - data, err := json.Marshal(postData) + data, err := JSONEncode(postData) if err != nil { return errors.New("Unable to JSON Marshal POST data") diff --git a/currency.go b/currency.go index 80cda4be..6548368f 100644 --- a/currency.go +++ b/currency.go @@ -3,7 +3,6 @@ package main import ( "fmt" "net/url" - "encoding/json" "strings" "time" "errors" @@ -128,7 +127,7 @@ func QueryYahooCurrencyValues(currencies string) (error) { return err } - err = json.Unmarshal([]byte(resp), &CurrencyStore) + err = JSONDecode([]byte(resp), &CurrencyStore) if err != nil { return err diff --git a/itbithttp.go b/itbithttp.go index 1b39d2dc..17075541 100644 --- a/itbithttp.go +++ b/itbithttp.go @@ -6,7 +6,6 @@ import ( "errors" "strings" "time" - "encoding/json" "log" ) @@ -275,7 +274,7 @@ func (i *ItBit) SendAuthenticatedHTTPRequest(method string, path string, params } } - PayloadJson, err := json.Marshal(request) + PayloadJson, err := JSONEncode(request) if err != nil { return errors.New("SendAuthenticatedHTTPRequest: Unable to JSON Marshal request") diff --git a/kraken.go b/kraken.go index 1e22214a..3e6c6dcd 100644 --- a/kraken.go +++ b/kraken.go @@ -4,7 +4,6 @@ import ( "log" "fmt" "strconv" - "encoding/json" "errors" "time" "strings" @@ -545,7 +544,7 @@ func (k *Kraken) SendAuthenticatedHTTPRequest(method string, values url.Values) } kresp := KrakenResponse{} - err = json.Unmarshal([]byte(resp), &kresp) + err = JSONDecode([]byte(resp), &kresp) if err != nil { return nil, errors.New("Unable to JSON response.")