forked from alecthomas/go_serialization_benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
structdef_easyjson.go
102 lines (98 loc) · 2.15 KB
/
structdef_easyjson.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// AUTOGENERATED FILE: easyjson marshaller/unmarshallers.
package goserbench
import (
json "encoding/json"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
var _ = json.RawMessage{} // suppress unused package warning
func easyjson_decode_go_serialization_benchmarks_A(in *jlexer.Lexer, out *A) {
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "Name":
out.Name = in.String()
case "BirthDay":
if data := in.Raw(); in.Ok() {
in.AddError((out.BirthDay).UnmarshalJSON(data))
}
case "Phone":
out.Phone = in.String()
case "Siblings":
out.Siblings = in.Int()
case "Spouse":
out.Spouse = in.Bool()
case "Money":
out.Money = in.Float64()
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
}
func easyjson_encode_go_serialization_benchmarks_A(out *jwriter.Writer, in *A) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"Name\":")
out.String(in.Name)
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"BirthDay\":")
out.Raw((in.BirthDay).MarshalJSON())
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"Phone\":")
out.String(in.Phone)
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"Siblings\":")
out.Int(in.Siblings)
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"Spouse\":")
out.Bool(in.Spouse)
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"Money\":")
out.Float64(in.Money)
out.RawByte('}')
}
func (v *A) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjson_encode_go_serialization_benchmarks_A(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
func (v *A) MarshalEasyJSON(w *jwriter.Writer) {
easyjson_encode_go_serialization_benchmarks_A(w, v)
}
func (v *A) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjson_decode_go_serialization_benchmarks_A(&r, v)
return r.Error()
}
func (v *A) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjson_decode_go_serialization_benchmarks_A(l, v)
}