From 1fc099c1be490f095df0d3ab405c493ac80b8d39 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Wed, 2 Nov 2022 12:53:30 +0300 Subject: [PATCH] add decode json method --- jsonUtils/jsonUtils.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/jsonUtils/jsonUtils.go b/jsonUtils/jsonUtils.go index c0387cb..4f0059e 100644 --- a/jsonUtils/jsonUtils.go +++ b/jsonUtils/jsonUtils.go @@ -1,9 +1,18 @@ package jsonutils -import "encoding/json" +//TODO: Rename package +import ( + "encoding/json" + "io" +) func ConvertToJSON(g interface{}) []byte { g_json, err := json.Marshal(g) _ = err //TODO: Check Errors return g_json } + +func ConvertFromJSON(body io.ReadCloser, inter interface{}) { + json_err := json.NewDecoder(body).Decode(&inter) + _ = json_err //TODO work with errors +}