ing
This commit is contained in:
parent
30fe3d0fdb
commit
9d8e274d6f
|
@ -44,15 +44,15 @@ func (st TargetType) String() string {
|
||||||
return targetTypeID[st]
|
return targetTypeID[st]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (st TargetType) MarshalJSON() ([]byte, error) {
|
func (st *TargetType) MarshalJSON() ([]byte, error) {
|
||||||
value, ok := targetTypeID[st]
|
value, ok := targetTypeID[*st]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("Invalid EnumType[%s] value", st)
|
return nil, fmt.Errorf("Invalid EnumType[%s] value", st)
|
||||||
}
|
}
|
||||||
return json.Marshal(value)
|
return json.Marshal(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (st TargetType) UnmarshalJSON(b []byte) error {
|
func (st *TargetType) UnmarshalJSON(b []byte) error {
|
||||||
// unmarshal as string
|
// unmarshal as string
|
||||||
var s string
|
var s string
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
@ -64,6 +64,6 @@ func (st TargetType) UnmarshalJSON(b []byte) error {
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("Invalid EnumType[%s] value", s)
|
return fmt.Errorf("Invalid EnumType[%s] value", s)
|
||||||
}
|
}
|
||||||
st = value
|
st = &value
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user