Files
steam_analyzer/pkg/utils/jsonutils/jsonutils.go
2026-01-17 22:45:02 +03:00

20 lines
415 B
Go

package jsonutils
import (
"encoding/json"
"io"
)
// ToJSON serializes the given interface into a string based JSON format
func ToJSON(i interface{}, w io.Writer) error {
e := json.NewEncoder(w)
return e.Encode(i)
}
// FromJSON deserializes the object from JSON string
// in an io.Reader to the given interface
func FromJSON(i interface{}, r io.Reader) error {
d := json.NewDecoder(r)
return d.Decode(i)
}