You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
598 B
Go
26 lines
598 B
Go
3 years ago
|
package json
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"ngs/serialize"
|
||
|
)
|
||
|
|
||
|
// Serializer implements the serialize.Serializer interface
|
||
|
type Serializer struct{}
|
||
|
|
||
|
// NewSerializer returns a new serialize.Serializer.
|
||
|
func NewSerializer() serialize.Serializer {
|
||
|
return &Serializer{}
|
||
|
}
|
||
|
|
||
|
// Marshal returns the JSON encoding of v.
|
||
|
func (s *Serializer) Marshal(v interface{}) ([]byte, error) {
|
||
|
return json.Marshal(v)
|
||
|
}
|
||
|
|
||
|
// Unmarshal parses the JSON-encoded data and stores the result
|
||
|
// in the value pointed to by v.
|
||
|
func (s *Serializer) Unmarshal(data []byte, v interface{}) error {
|
||
|
return json.Unmarshal(data, v)
|
||
|
}
|