This commit is contained in:
sentriz
2022-11-03 15:27:59 +00:00
parent 5c6855f671
commit 1f8de66fc0
6 changed files with 24 additions and 25 deletions

View File

@@ -75,15 +75,15 @@ func (i ID) MarshalJSON() ([]byte, error) {
return json.Marshal(i.String())
}
func (i *ID) UnmarshalJSON(data []byte) (error) {
if (len(data) <= 2) {
func (i *ID) UnmarshalJSON(data []byte) error {
if len(data) <= 2 {
return fmt.Errorf("too short: %w", ErrBadJSON)
}
id, err := New(string(data[1:len(data)-1])) // Strip quotes
if (err == nil) {
*i = id;
id, err := New(string(data[1 : len(data)-1])) // Strip quotes
if err == nil {
*i = id
}
return err;
return err
}
func (i ID) MarshalText() ([]byte, error) {