mirror of
https://github.com/number571/go-peer.git
synced 2026-09-13 18:45:44 +05:00
20 lines
362 B
Go
20 lines
362 B
Go
package encoding
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/number571/go-peer/pkg/utils"
|
|
)
|
|
|
|
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 utils.MergeErrors(ErrDeserialize, err)
|
|
}
|
|
return nil
|
|
}
|