add decode json method
This commit is contained in:
parent
39232f8664
commit
1fc099c1be
@ -1,9 +1,18 @@
|
|||||||
package jsonutils
|
package jsonutils
|
||||||
|
|
||||||
import "encoding/json"
|
//TODO: Rename package
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
func ConvertToJSON(g interface{}) []byte {
|
func ConvertToJSON(g interface{}) []byte {
|
||||||
g_json, err := json.Marshal(g)
|
g_json, err := json.Marshal(g)
|
||||||
_ = err //TODO: Check Errors
|
_ = err //TODO: Check Errors
|
||||||
return g_json
|
return g_json
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ConvertFromJSON(body io.ReadCloser, inter interface{}) {
|
||||||
|
json_err := json.NewDecoder(body).Decode(&inter)
|
||||||
|
_ = json_err //TODO work with errors
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user