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.
ntool/ngo/codec/serializer_json.go

26 lines
451 B
Go

package codec
import (
"encoding/json"
"git.noahlan.cn/noahlan/ntool/ndef"
)
type JsonSerializer struct {
}
func NewJsonSerializer() ndef.Serializer {
return &JsonSerializer{}
}
func (s *JsonSerializer) Marshal(v interface{}) ([]byte, error) {
marshal, err := json.Marshal(v)
if err != nil {
return nil, err
}
return marshal, nil
}
func (s *JsonSerializer) Unmarshal(data []byte, v interface{}) error {
return json.Unmarshal(data, v)
}