-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpayload_response_json.go
50 lines (42 loc) · 1.1 KB
/
payload_response_json.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
package valuefirst
import (
"encoding/json"
)
var (
_ json.Unmarshaler = new(ResponseMessageAck)
_ json.Unmarshaler = new(ResponseMessageAckGUID)
)
// UnmarshalJSON implements the json.Unmarshaler interface.
func (r *ResponseMessageAck) UnmarshalJSON(data []byte) (err error) {
var result map[string]interface{}
err = json.Unmarshal(data, &result)
if err != nil {
return
}
switch result["GUID"].(type) {
case map[string]interface{}:
r.GUID = new(ResponseMessageAckGUID)
case []interface{}:
r.GUID = new(ResponseMessageAckGUIDs)
}
type tmp ResponseMessageAck
err = json.Unmarshal(data, (*tmp)(r))
return
}
// UnmarshalJSON implements the json.Unmarshaler interface.
func (r *ResponseMessageAckGUID) UnmarshalJSON(data []byte) (err error) {
var result map[string]interface{}
err = json.Unmarshal(data, &result)
if err != nil {
return
}
switch result["ERROR"].(type) {
case map[string]interface{}:
r.Error = new(ResponseMessageAckGUIDError)
case []interface{}:
r.Error = new(ResponseMessageAckGUIDErrors)
}
type tmp ResponseMessageAckGUID
err = json.Unmarshal(data, (*tmp)(r))
return
}