-
Notifications
You must be signed in to change notification settings - Fork 132
/
deserialize.go
79 lines (74 loc) · 1.45 KB
/
deserialize.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package api
import (
"encoding/json"
"fmt"
)
func (x *IngressType) UnmarshalJSON(data []byte) error {
var s int32
e := json.Unmarshal(data, &s)
if e == nil {
_, present := IngressType_name[s]
if !present {
return fmt.Errorf("no IngressType of type %d", s)
}
*x = IngressType(s)
return nil
}
var t string
e = json.Unmarshal(data, &t)
if e != nil {
return e
}
value, present := IngressType_value[t]
if !present {
return fmt.Errorf("no IngressType of type %s", t)
}
*x = IngressType(value)
return nil
}
func (x *ServiceType) UnmarshalJSON(data []byte) error {
var s int32
e := json.Unmarshal(data, &s)
if e == nil {
_, present := ServiceType_name[s]
if !present {
return fmt.Errorf("no ServiceType of type %d", s)
}
*x = ServiceType(s)
return nil
}
var t string
e = json.Unmarshal(data, &t)
if e != nil {
return e
}
value, present := ServiceType_value[t]
if !present {
return fmt.Errorf("no ServiceType of type %s", t)
}
*x = ServiceType(value)
return nil
}
func (x *JobState) UnmarshalJSON(data []byte) error {
var s int32
e := json.Unmarshal(data, &s)
if e == nil {
_, present := JobState_name[s]
if !present {
return fmt.Errorf("no JobState of type %d", s)
}
*x = JobState(s)
return nil
}
var t string
e = json.Unmarshal(data, &t)
if e != nil {
return e
}
value, present := JobState_value[t]
if !present {
return fmt.Errorf("no JobState of type %s", t)
}
*x = JobState(value)
return nil
}