This update replaces instances of DecodeJson and DecodeJsonStr with UnmarshalJson and UnmarshalJsonStr in various relay handlers, enhancing code consistency and clarity in JSON processing. The changes improve maintainability and align with recent refactoring efforts in the codebase.
23 lines
405 B
Go
23 lines
405 B
Go
package common
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
)
|
|
|
|
func UnmarshalJson(data []byte, v any) error {
|
|
return json.Unmarshal(data, v)
|
|
}
|
|
|
|
func UnmarshalJsonStr(data string, v any) error {
|
|
return json.Unmarshal(StringToByteSlice(data), v)
|
|
}
|
|
|
|
func DecodeJson(reader *bytes.Reader, v any) error {
|
|
return json.NewDecoder(reader).Decode(v)
|
|
}
|
|
|
|
func EncodeJson(v any) ([]byte, error) {
|
|
return json.Marshal(v)
|
|
}
|