mirror of
https://github.com/number571/go-peer.git
synced 2026-09-12 19:50:00 +05:00
19 lines
323 B
Go
19 lines
323 B
Go
package encoding
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
)
|
|
|
|
func SerializeJSON(pData interface{}) []byte {
|
|
res, _ := json.Marshal(pData)
|
|
return res
|
|
}
|
|
|
|
func DeserializeJSON(pData []byte, pRes interface{}) error {
|
|
if err := json.Unmarshal(pData, pRes); err != nil {
|
|
return errors.Join(ErrDeserialize, err)
|
|
}
|
|
return nil
|
|
}
|