comparison pkg/models/isrs.go @ 1911:6ffc372cde1e

Fixed JSON serialization of ISRS codes.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 18 Jan 2019 17:50:25 +0100
parents 6a67cd819e93
children 4a7c2140e44b
comparison
equal deleted inserted replaced
1910:146369b1c376 1911:6ffc372cde1e
41 } 41 }
42 *isrs = *in 42 *isrs = *in
43 return nil 43 return nil
44 } 44 }
45 45
46 func (isrs *Isrs) MarshalJSON() ([]byte, error) {
47 if isrs == nil {
48 return nil, nil
49 }
50 return json.Marshal(isrs.String())
51 }
52
46 // IsrsFromString converts string representation of isrs code to type Isrs 53 // IsrsFromString converts string representation of isrs code to type Isrs
47 func IsrsFromString(isrsCode string) (*Isrs, error) { 54 func IsrsFromString(isrsCode string) (*Isrs, error) {
48 if len(isrsCode) < 20 { 55 if len(isrsCode) < 20 {
49 return nil, errors.New("ISRS code too short") 56 return nil, errors.New("ISRS code too short")
50 } 57 }