-
Notifications
You must be signed in to change notification settings - Fork 1
/
WithStructTag_json.go
44 lines (42 loc) · 1.33 KB
/
WithStructTag_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
package value_tests
import jsoniter "github.com/json-iterator/tinygo"
type WithStructTag_json struct {
}
func (json WithStructTag_json) Type() interface{} {
var val WithStructTag
return val
}
func (json WithStructTag_json) Unmarshal(iter *jsoniter.Iterator, out interface{}) {
WithStructTag_json_unmarshal(iter, out.(*WithStructTag))
}
func (json WithStructTag_json) Marshal(stream *jsoniter.Stream, val interface{}) {
WithStructTag_json_marshal(stream, val.(WithStructTag))
}
func WithStructTag_json_unmarshal(iter *jsoniter.Iterator, out *WithStructTag) {
more := iter.ReadObjectHead()
for more {
field := iter.ReadObjectField()
if !WithStructTag_json_unmarshal_field(iter, field, out) {
iter.Skip()
}
more = iter.ReadObjectMore()
}
}
func WithStructTag_json_unmarshal_field(iter *jsoniter.Iterator, field string, out *WithStructTag) bool {
switch {
case field == `field1`:
iter.ReadString(&(*out).Field1)
return true
}
return false
}
func WithStructTag_json_marshal(stream *jsoniter.Stream, val WithStructTag) {
stream.WriteObjectHead()
WithStructTag_json_marshal_field(stream, val)
stream.WriteObjectTail()
}
func WithStructTag_json_marshal_field(stream *jsoniter.Stream, val WithStructTag) {
stream.WriteObjectField(`field1`)
stream.WriteString(val.Field1)
stream.WriteMore()
}