parent
							
								
									241b86fc6a
								
							
						
					
					
						commit
						ce131a3866
					
				| @ -1,25 +0,0 @@ | ||||
| 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) | ||||
| } | ||||
| @ -0,0 +1,24 @@ | ||||
| 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) | ||||
| } | ||||
					Loading…
					
					
				
		Reference in New Issue