add decode json method

This commit is contained in:
cyber-dream 2022-11-02 12:53:30 +03:00
parent 39232f8664
commit 1fc099c1be

View File

@ -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
}