/
gen_candidate_list_res_json.go
45 lines (39 loc) · 1.26 KB
/
gen_candidate_list_res_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
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package node
import (
"encoding/json"
"errors"
"github.com/LemoFoundationLtd/lemochain-core/common/hexutil"
)
var _ = (*candidateListResMarshaling)(nil)
// MarshalJSON marshals as JSON.
func (c CandidateListRes) MarshalJSON() ([]byte, error) {
type CandidateListRes struct {
CandidateList []*CandidateInfo `json:"candidateList" gencodec:"required"`
Total hexutil.Uint32 `json:"total" gencodec:"required"`
}
var enc CandidateListRes
enc.CandidateList = c.CandidateList
enc.Total = hexutil.Uint32(c.Total)
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (c *CandidateListRes) UnmarshalJSON(input []byte) error {
type CandidateListRes struct {
CandidateList []*CandidateInfo `json:"candidateList" gencodec:"required"`
Total *hexutil.Uint32 `json:"total" gencodec:"required"`
}
var dec CandidateListRes
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.CandidateList == nil {
return errors.New("missing required field 'candidateList' for CandidateListRes")
}
c.CandidateList = dec.CandidateList
if dec.Total == nil {
return errors.New("missing required field 'total' for CandidateListRes")
}
c.Total = uint32(*dec.Total)
return nil
}