...
1 package jreader
2
3 import (
4 "github.com/launchdarkly/go-jsonstream/v3/internal/commontest"
5 )
6
7
8 type ExampleStructWrapper commontest.ExampleStruct
9
10 type ExampleStructWrapperWithRequiredProps commontest.ExampleStruct
11
12 func (s *ExampleStructWrapper) ReadFromJSONReader(r *Reader) {
13 for obj := r.Object(); obj.Next(); {
14 switch string(obj.Name()) {
15 case commontest.ExampleStructStringFieldName:
16 s.StringField = r.String()
17 case commontest.ExampleStructIntFieldName:
18 s.IntField = r.Int()
19 case commontest.ExampleStructOptBoolAsInterfaceFieldName:
20 b, nonNull := r.BoolOrNull()
21 if nonNull {
22 s.OptBoolAsInterfaceField = b
23 } else {
24 s.OptBoolAsInterfaceField = nil
25 }
26 }
27 }
28 }
29
30 func (s *ExampleStructWrapperWithRequiredProps) ReadFromJSONReader(r *Reader) {
31 for obj := r.Object().WithRequiredProperties(commontest.ExampleStructRequiredFieldNames); obj.Next(); {
32 switch string(obj.Name()) {
33 case commontest.ExampleStructStringFieldName:
34 s.StringField = r.String()
35 case commontest.ExampleStructIntFieldName:
36 s.IntField = r.Int()
37 case commontest.ExampleStructOptBoolAsInterfaceFieldName:
38 b, nonNull := r.BoolOrNull()
39 if nonNull {
40 s.OptBoolAsInterfaceField = b
41 } else {
42 s.OptBoolAsInterfaceField = nil
43 }
44 }
45 }
46 }
47
View as plain text