-
Notifications
You must be signed in to change notification settings - Fork 0
/
model_tags_1.go
177 lines (147 loc) · 3.73 KB
/
model_tags_1.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
Carbon
Connect external data to LLMs, no matter the source.
API version: 1.0.0
*/
// Code generated by Konfig (https://konfigthis.com); DO NOT EDIT.
package carbon
import (
"encoding/json"
"fmt"
)
// Tags1 struct for Tags1
type Tags1 struct {
BoolArray *[]bool
Int32Array *[]int32
StringArray *[]string
Bool *bool
Int32 *int32
String *string
}
// Unmarshal JSON data into any of the pointers in the struct
func (dst *Tags1) UnmarshalJSON(data []byte) error {
var err error
// try to unmarshal JSON data into []bool
err = json.Unmarshal(data, &dst.BoolArray);
if err == nil {
jsonBoolArray, _ := json.Marshal(dst.BoolArray)
if string(jsonBoolArray) == "{}" { // empty struct
dst.BoolArray = nil
} else {
return nil // data stored in dst.BoolArray, return on the first match
}
} else {
dst.BoolArray = nil
}
// try to unmarshal JSON data into []int32
err = json.Unmarshal(data, &dst.Int32Array);
if err == nil {
jsonInt32Array, _ := json.Marshal(dst.Int32Array)
if string(jsonInt32Array) == "{}" { // empty struct
dst.Int32Array = nil
} else {
return nil // data stored in dst.Int32Array, return on the first match
}
} else {
dst.Int32Array = nil
}
// try to unmarshal JSON data into []string
err = json.Unmarshal(data, &dst.StringArray);
if err == nil {
jsonStringArray, _ := json.Marshal(dst.StringArray)
if string(jsonStringArray) == "{}" { // empty struct
dst.StringArray = nil
} else {
return nil // data stored in dst.StringArray, return on the first match
}
} else {
dst.StringArray = nil
}
// try to unmarshal JSON data into bool
err = json.Unmarshal(data, &dst.Bool);
if err == nil {
jsonBool, _ := json.Marshal(dst.Bool)
if string(jsonBool) == "{}" { // empty struct
dst.Bool = nil
} else {
return nil // data stored in dst.Bool, return on the first match
}
} else {
dst.Bool = nil
}
// try to unmarshal JSON data into int32
err = json.Unmarshal(data, &dst.Int32);
if err == nil {
jsonInt32, _ := json.Marshal(dst.Int32)
if string(jsonInt32) == "{}" { // empty struct
dst.Int32 = nil
} else {
return nil // data stored in dst.Int32, return on the first match
}
} else {
dst.Int32 = nil
}
// try to unmarshal JSON data into string
err = json.Unmarshal(data, &dst.String);
if err == nil {
jsonString, _ := json.Marshal(dst.String)
if string(jsonString) == "{}" { // empty struct
dst.String = nil
} else {
return nil // data stored in dst.String, return on the first match
}
} else {
dst.String = nil
}
return fmt.Errorf("data failed to match schemas in anyOf(Tags1)")
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src *Tags1) MarshalJSON() ([]byte, error) {
if src.BoolArray != nil {
return json.Marshal(&src.BoolArray)
}
if src.Int32Array != nil {
return json.Marshal(&src.Int32Array)
}
if src.StringArray != nil {
return json.Marshal(&src.StringArray)
}
if src.Bool != nil {
return json.Marshal(&src.Bool)
}
if src.Int32 != nil {
return json.Marshal(&src.Int32)
}
if src.String != nil {
return json.Marshal(&src.String)
}
return nil, nil // no data in anyOf schemas
}
type NullableTags1 struct {
value *Tags1
isSet bool
}
func (v NullableTags1) Get() *Tags1 {
return v.value
}
func (v *NullableTags1) Set(val *Tags1) {
v.value = val
v.isSet = true
}
func (v NullableTags1) IsSet() bool {
return v.isSet
}
func (v *NullableTags1) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTags1(val *Tags1) *NullableTags1 {
return &NullableTags1{value: val, isSet: true}
}
func (v NullableTags1) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTags1) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}