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.
25 lines
408 B
Go
25 lines
408 B
Go
package njson
|
|
|
|
import (
|
|
"git.noahlan.cn/noahlan/ntool/ndef"
|
|
)
|
|
|
|
type JsonSerializer struct {
|
|
}
|
|
|
|
func NewJsonSerializer() ndef.Serializer {
|
|
return &JsonSerializer{}
|
|
}
|
|
|
|
func (s *JsonSerializer) Marshal(v any) ([]byte, error) {
|
|
marshal, err := Marshal(v)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return marshal, nil
|
|
}
|
|
|
|
func (s *JsonSerializer) Unmarshal(data []byte, v any) error {
|
|
return Unmarshal(data, v)
|
|
}
|