...
1
2
3 package ldvalue
4
5 import (
6 "github.com/mailru/easyjson/jlexer"
7 ej_jwriter "github.com/mailru/easyjson/jwriter"
8 )
9
10
11
12
13
14 func (v OptionalBool) MarshalEasyJSON(writer *ej_jwriter.Writer) {
15 if value, ok := v.optValue.get(); ok {
16 writer.Bool(value)
17 } else {
18 writer.Raw(nullAsJSONBytes, nil)
19 }
20 }
21
22
23
24
25
26 func (v OptionalInt) MarshalEasyJSON(writer *ej_jwriter.Writer) {
27 if value, ok := v.optValue.get(); ok {
28 writer.Int(value)
29 } else {
30 writer.Raw(nullAsJSONBytes, nil)
31 }
32 }
33
34
35
36
37
38 func (v OptionalString) MarshalEasyJSON(writer *ej_jwriter.Writer) {
39 if value, ok := v.optValue.get(); ok {
40 writer.String(value)
41 } else {
42 writer.Raw(nullAsJSONBytes, nil)
43 }
44 }
45
46
47
48
49
50 func (v *OptionalBool) UnmarshalEasyJSON(lexer *jlexer.Lexer) {
51 if lexer.IsNull() {
52 lexer.Null()
53 *v = OptionalBool{}
54 return
55 }
56 *v = NewOptionalBool(lexer.Bool())
57 }
58
59
60
61
62
63 func (v *OptionalInt) UnmarshalEasyJSON(lexer *jlexer.Lexer) {
64 if lexer.IsNull() {
65 lexer.Null()
66 *v = OptionalInt{}
67 return
68 }
69 *v = NewOptionalInt(lexer.Int())
70 }
71
72
73
74
75
76 func (v *OptionalString) UnmarshalEasyJSON(lexer *jlexer.Lexer) {
77 if lexer.IsNull() {
78 lexer.Null()
79 *v = OptionalString{}
80 return
81 }
82 *v = NewOptionalString(lexer.String())
83 }
84
View as plain text