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) }