mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-21 07:26:48 +00:00
Added common JSON encoding function.
This commit is contained in:
10
common.go
10
common.go
@@ -194,6 +194,16 @@ func SendHTTPGetRequest(url string, jsonDecode bool, result interface{}) (err er
|
||||
return nil
|
||||
}
|
||||
|
||||
func JSONEncode(v interface{}) ([]byte, error) {
|
||||
json, err := json.Marshal(&v)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json, nil
|
||||
}
|
||||
|
||||
func JSONDecode(data []byte, to interface{}) (error) {
|
||||
err := json.Unmarshal(data, &to)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user