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 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
|
package gojay
type testObject struct {
testStr string
testStrNull *string
testInt int
testIntNull *int
testInt64 int64
testInt64Null *int64
testInt32 int32
testInt32Null *int32
testInt16 int16
testInt16Null *int16
testInt8 int8
testInt8Null *int8
testUint64 uint64
testUint64Null *uint64
testUint32 uint32
testUint32Null *uint32
testUint16 uint16
testUint16Null *uint16
testUint8 uint8
testUint8Null *uint8
testFloat64 float64
testFloat64Null *float64
testFloat32 float32
testFloat32Null *float32
testBool bool
testBoolNull *bool
testSubObject *testObject
testSubArray testSliceInts
testInterface interface{}
}
// make sure it implements interfaces
var _ MarshalerJSONObject = &testObject{}
var _ UnmarshalerJSONObject = &testObject{}
func (t *testObject) IsNil() bool {
return t == nil
}
func (t *testObject) MarshalJSONObject(enc *Encoder) {
enc.AddStringKey("testStr", t.testStr)
enc.AddIntKey("testInt", t.testInt)
enc.AddIntKey("testInt64", int(t.testInt64))
enc.AddIntKey("testInt32", int(t.testInt32))
enc.AddIntKey("testInt16", int(t.testInt16))
enc.AddIntKey("testInt8", int(t.testInt8))
enc.AddIntKey("testUint64", int(t.testUint64))
enc.AddIntKey("testUint32", int(t.testUint32))
enc.AddIntKey("testUint16", int(t.testUint16))
enc.AddIntKey("testUint8", int(t.testUint8))
enc.AddFloatKey("testFloat64", t.testFloat64)
enc.AddFloat32Key("testFloat32", t.testFloat32)
enc.AddBoolKey("testBool", t.testBool)
}
func (t *testObject) UnmarshalJSONObject(dec *Decoder, k string) error {
switch k {
case "testStr":
return dec.AddString(&t.testStr)
case "testStrNull":
return dec.AddStringNull(&t.testStrNull)
case "testInt":
return dec.AddInt(&t.testInt)
case "testIntNull":
return dec.AddIntNull(&t.testIntNull)
case "testInt64":
return dec.AddInt64(&t.testInt64)
case "testInt64Null":
return dec.AddInt64Null(&t.testInt64Null)
case "testInt32":
return dec.AddInt32(&t.testInt32)
case "testInt32Null":
return dec.AddInt32Null(&t.testInt32Null)
case "testInt16":
return dec.AddInt16(&t.testInt16)
case "testInt16Null":
return dec.AddInt16Null(&t.testInt16Null)
case "testInt8":
return dec.AddInt8(&t.testInt8)
case "testInt8Null":
return dec.AddInt8Null(&t.testInt8Null)
case "testUint64":
return dec.AddUint64(&t.testUint64)
case "testUint64Null":
return dec.AddUint64Null(&t.testUint64Null)
case "testUint32":
return dec.AddUint32(&t.testUint32)
case "testUint32Null":
return dec.AddUint32Null(&t.testUint32Null)
case "testUint16":
return dec.AddUint16(&t.testUint16)
case "testUint16Null":
return dec.AddUint16Null(&t.testUint16Null)
case "testUint8":
return dec.AddUint8(&t.testUint8)
case "testUint8Null":
return dec.AddUint8Null(&t.testUint8Null)
case "testFloat64":
return dec.AddFloat(&t.testFloat64)
case "testFloat64Null":
return dec.AddFloatNull(&t.testFloat64Null)
case "testFloat32":
return dec.AddFloat32(&t.testFloat32)
case "testFloat32Null":
return dec.AddFloat32Null(&t.testFloat32Null)
case "testBool":
return dec.AddBool(&t.testBool)
case "testBoolNull":
return dec.AddBoolNull(&t.testBoolNull)
case "testInterface":
return dec.AddInterface(&t.testInterface)
}
return nil
}
func (t *testObject) NKeys() int {
return 29
}
type testObject0Keys struct {
testStr string
testInt int
testInt64 int64
testInt32 int32
testInt16 int16
testInt8 int8
testUint64 uint64
testUint32 uint32
testUint16 uint16
testUint8 uint8
testFloat64 float64
testFloat32 float32
testBool bool
testSubObject *testObject0Keys
testSubArray testSliceInts
testInterface interface{}
}
// make sure it implements interfaces
var _ MarshalerJSONObject = &testObject0Keys{}
var _ UnmarshalerJSONObject = &testObject0Keys{}
func (t *testObject0Keys) IsNil() bool {
return t == nil
}
func (t *testObject0Keys) MarshalJSONObject(enc *Encoder) {
enc.AddStringKey("testStr", t.testStr)
enc.AddIntKey("testInt", t.testInt)
enc.AddIntKey("testInt64", int(t.testInt64))
enc.AddIntKey("testInt32", int(t.testInt32))
enc.AddIntKey("testInt16", int(t.testInt16))
enc.AddIntKey("testInt8", int(t.testInt8))
enc.AddIntKey("testUint64", int(t.testUint64))
enc.AddIntKey("testUint32", int(t.testUint32))
enc.AddIntKey("testUint16", int(t.testUint16))
enc.AddIntKey("testUint8", int(t.testUint8))
enc.AddFloatKey("testFloat64", t.testFloat64)
enc.AddFloat32Key("testFloat32", t.testFloat32)
enc.AddBoolKey("testBool", t.testBool)
enc.AddInterfaceKey("testInterface", t.testInterface)
}
func (t *testObject0Keys) UnmarshalJSONObject(dec *Decoder, k string) error {
switch k {
case "testStr":
return dec.AddString(&t.testStr)
case "testInt":
return dec.AddInt(&t.testInt)
case "testInt64":
return dec.AddInt64(&t.testInt64)
case "testInt32":
return dec.AddInt32(&t.testInt32)
case "testInt16":
return dec.AddInt16(&t.testInt16)
case "testInt8":
return dec.AddInt8(&t.testInt8)
case "testUint64":
return dec.AddUint64(&t.testUint64)
case "testUint32":
return dec.AddUint32(&t.testUint32)
case "testUint16":
return dec.AddUint16(&t.testUint16)
case "testUint8":
return dec.AddUint8(&t.testUint8)
case "testFloat64":
return dec.AddFloat(&t.testFloat64)
case "testFloat32":
return dec.AddFloat32(&t.testFloat32)
case "testBool":
return dec.AddBool(&t.testBool)
case "testInterface":
return dec.AddInterface(&t.testInterface)
}
return nil
}
func (t *testObject0Keys) NKeys() int {
return 0
}
type testObjectComplex struct {
testSubObject *testObject
testSubSliceInts *testSliceInts
testStr string
testSubObject2 *testObjectComplex
}
func (t *testObjectComplex) IsNil() bool {
return t == nil
}
func (t *testObjectComplex) MarshalJSONObject(enc *Encoder) {
enc.AddObjectKey("testSubObject", t.testSubObject)
enc.AddStringKey("testStr", t.testStr)
enc.AddObjectKey("testStr", t.testSubObject2)
}
func (t *testObjectComplex) UnmarshalJSONObject(dec *Decoder, k string) error {
switch k {
case "testSubObject":
return dec.AddObject(t.testSubObject)
case "testSubSliceInts":
return dec.AddArray(t.testSubSliceInts)
case "testStr":
return dec.AddString(&t.testStr)
case "testSubObject2":
return dec.AddObject(t.testSubObject2)
}
return nil
}
func (t *testObjectComplex) NKeys() int {
return 4
}
// make sure it implements interfaces
var _ MarshalerJSONObject = &testObjectComplex{}
var _ UnmarshalerJSONObject = &testObjectComplex{}
type TestObj struct {
test int
test2 int
test3 string
test4 string
test5 float64
testArr testSliceObjects
testSubObj *TestSubObj
testSubObj2 *TestSubObj
}
type TestSubObj struct {
test3 int
test4 int
test5 string
testSubSubObj *TestSubObj
testSubSubObj2 *TestSubObj
}
func (t *TestSubObj) UnmarshalJSONObject(dec *Decoder, key string) error {
switch key {
case "test":
return dec.AddInt(&t.test3)
case "test2":
return dec.AddInt(&t.test4)
case "test3":
return dec.AddString(&t.test5)
case "testSubSubObj":
t.testSubSubObj = &TestSubObj{}
return dec.AddObject(t.testSubSubObj)
case "testSubSubObj2":
t.testSubSubObj2 = &TestSubObj{}
return dec.AddObject(t.testSubSubObj2)
}
return nil
}
func (t *TestSubObj) NKeys() int {
return 0
}
func (t *TestObj) UnmarshalJSONObject(dec *Decoder, key string) error {
switch key {
case "test":
return dec.AddInt(&t.test)
case "test2":
return dec.AddInt(&t.test2)
case "test3":
return dec.AddString(&t.test3)
case "test4":
return dec.AddString(&t.test4)
case "test5":
return dec.AddFloat(&t.test5)
case "testSubObj":
t.testSubObj = &TestSubObj{}
return dec.AddObject(t.testSubObj)
case "testSubObj2":
t.testSubObj2 = &TestSubObj{}
return dec.AddObject(t.testSubObj2)
case "testArr":
return dec.AddArray(&t.testArr)
}
return nil
}
func (t *TestObj) NKeys() int {
return 8
}
|