File size: 322 Bytes
df5a20a bce5831 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | package common
import (
"bytes"
"encoding/json"
)
func DecodeJson(data []byte, v any) error {
return json.NewDecoder(bytes.NewReader(data)).Decode(v)
}
func DecodeJsonStr(data string, v any) error {
return DecodeJson(StringToByteSlice(data), v)
}
func EncodeJson(v any) ([]byte, error) {
return json.Marshal(v)
}
|