data.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. package tests
  2. import (
  3. "fmt"
  4. "math"
  5. "net"
  6. "time"
  7. "github.com/mailru/easyjson"
  8. "github.com/mailru/easyjson/opt"
  9. )
  10. type PrimitiveTypes struct {
  11. String string
  12. Bool bool
  13. Int int
  14. Int8 int8
  15. Int16 int16
  16. Int32 int32
  17. Int64 int64
  18. Uint uint
  19. Uint8 uint8
  20. Uint16 uint16
  21. Uint32 uint32
  22. Uint64 uint64
  23. IntString int `json:",string"`
  24. Int8String int8 `json:",string"`
  25. Int16String int16 `json:",string"`
  26. Int32String int32 `json:",string"`
  27. Int64String int64 `json:",string"`
  28. UintString uint `json:",string"`
  29. Uint8String uint8 `json:",string"`
  30. Uint16String uint16 `json:",string"`
  31. Uint32String uint32 `json:",string"`
  32. Uint64String uint64 `json:",string"`
  33. Float32 float32
  34. Float64 float64
  35. Float32String float32 `json:",string"`
  36. Float64String float64 `json:",string"`
  37. Ptr *string
  38. PtrNil *string
  39. }
  40. var str = "bla"
  41. var primitiveTypesValue = PrimitiveTypes{
  42. String: "test", Bool: true,
  43. Int: math.MinInt32,
  44. Int8: math.MinInt8,
  45. Int16: math.MinInt16,
  46. Int32: math.MinInt32,
  47. Int64: math.MinInt64,
  48. Uint: math.MaxUint32,
  49. Uint8: math.MaxUint8,
  50. Uint16: math.MaxUint16,
  51. Uint32: math.MaxUint32,
  52. Uint64: math.MaxUint64,
  53. IntString: math.MinInt32,
  54. Int8String: math.MinInt8,
  55. Int16String: math.MinInt16,
  56. Int32String: math.MinInt32,
  57. Int64String: math.MinInt64,
  58. UintString: math.MaxUint32,
  59. Uint8String: math.MaxUint8,
  60. Uint16String: math.MaxUint16,
  61. Uint32String: math.MaxUint32,
  62. Uint64String: math.MaxUint64,
  63. Float32: 1.5,
  64. Float64: math.MaxFloat64,
  65. Float32String: 1.5,
  66. Float64String: math.MaxFloat64,
  67. Ptr: &str,
  68. }
  69. var primitiveTypesString = "{" +
  70. `"String":"test","Bool":true,` +
  71. `"Int":` + fmt.Sprint(math.MinInt32) + `,` +
  72. `"Int8":` + fmt.Sprint(math.MinInt8) + `,` +
  73. `"Int16":` + fmt.Sprint(math.MinInt16) + `,` +
  74. `"Int32":` + fmt.Sprint(math.MinInt32) + `,` +
  75. `"Int64":` + fmt.Sprint(int64(math.MinInt64)) + `,` +
  76. `"Uint":` + fmt.Sprint(uint32(math.MaxUint32)) + `,` +
  77. `"Uint8":` + fmt.Sprint(math.MaxUint8) + `,` +
  78. `"Uint16":` + fmt.Sprint(math.MaxUint16) + `,` +
  79. `"Uint32":` + fmt.Sprint(uint32(math.MaxUint32)) + `,` +
  80. `"Uint64":` + fmt.Sprint(uint64(math.MaxUint64)) + `,` +
  81. `"IntString":"` + fmt.Sprint(math.MinInt32) + `",` +
  82. `"Int8String":"` + fmt.Sprint(math.MinInt8) + `",` +
  83. `"Int16String":"` + fmt.Sprint(math.MinInt16) + `",` +
  84. `"Int32String":"` + fmt.Sprint(math.MinInt32) + `",` +
  85. `"Int64String":"` + fmt.Sprint(int64(math.MinInt64)) + `",` +
  86. `"UintString":"` + fmt.Sprint(uint32(math.MaxUint32)) + `",` +
  87. `"Uint8String":"` + fmt.Sprint(math.MaxUint8) + `",` +
  88. `"Uint16String":"` + fmt.Sprint(math.MaxUint16) + `",` +
  89. `"Uint32String":"` + fmt.Sprint(uint32(math.MaxUint32)) + `",` +
  90. `"Uint64String":"` + fmt.Sprint(uint64(math.MaxUint64)) + `",` +
  91. `"Float32":` + fmt.Sprint(1.5) + `,` +
  92. `"Float64":` + fmt.Sprint(math.MaxFloat64) + `,` +
  93. `"Float32String":"` + fmt.Sprint(1.5) + `",` +
  94. `"Float64String":"` + fmt.Sprint(math.MaxFloat64) + `",` +
  95. `"Ptr":"bla",` +
  96. `"PtrNil":null` +
  97. "}"
  98. type (
  99. NamedString string
  100. NamedBool bool
  101. NamedInt int
  102. NamedInt8 int8
  103. NamedInt16 int16
  104. NamedInt32 int32
  105. NamedInt64 int64
  106. NamedUint uint
  107. NamedUint8 uint8
  108. NamedUint16 uint16
  109. NamedUint32 uint32
  110. NamedUint64 uint64
  111. NamedFloat32 float32
  112. NamedFloat64 float64
  113. NamedStrPtr *string
  114. )
  115. type NamedPrimitiveTypes struct {
  116. String NamedString
  117. Bool NamedBool
  118. Int NamedInt
  119. Int8 NamedInt8
  120. Int16 NamedInt16
  121. Int32 NamedInt32
  122. Int64 NamedInt64
  123. Uint NamedUint
  124. Uint8 NamedUint8
  125. Uint16 NamedUint16
  126. Uint32 NamedUint32
  127. Uint64 NamedUint64
  128. Float32 NamedFloat32
  129. Float64 NamedFloat64
  130. Ptr NamedStrPtr
  131. PtrNil NamedStrPtr
  132. }
  133. var namedPrimitiveTypesValue = NamedPrimitiveTypes{
  134. String: "test",
  135. Bool: true,
  136. Int: math.MinInt32,
  137. Int8: math.MinInt8,
  138. Int16: math.MinInt16,
  139. Int32: math.MinInt32,
  140. Int64: math.MinInt64,
  141. Uint: math.MaxUint32,
  142. Uint8: math.MaxUint8,
  143. Uint16: math.MaxUint16,
  144. Uint32: math.MaxUint32,
  145. Uint64: math.MaxUint64,
  146. Float32: 1.5,
  147. Float64: math.MaxFloat64,
  148. Ptr: NamedStrPtr(&str),
  149. }
  150. var namedPrimitiveTypesString = "{" +
  151. `"String":"test",` +
  152. `"Bool":true,` +
  153. `"Int":` + fmt.Sprint(math.MinInt32) + `,` +
  154. `"Int8":` + fmt.Sprint(math.MinInt8) + `,` +
  155. `"Int16":` + fmt.Sprint(math.MinInt16) + `,` +
  156. `"Int32":` + fmt.Sprint(math.MinInt32) + `,` +
  157. `"Int64":` + fmt.Sprint(int64(math.MinInt64)) + `,` +
  158. `"Uint":` + fmt.Sprint(uint32(math.MaxUint32)) + `,` +
  159. `"Uint8":` + fmt.Sprint(math.MaxUint8) + `,` +
  160. `"Uint16":` + fmt.Sprint(math.MaxUint16) + `,` +
  161. `"Uint32":` + fmt.Sprint(uint32(math.MaxUint32)) + `,` +
  162. `"Uint64":` + fmt.Sprint(uint64(math.MaxUint64)) + `,` +
  163. `"Float32":` + fmt.Sprint(1.5) + `,` +
  164. `"Float64":` + fmt.Sprint(math.MaxFloat64) + `,` +
  165. `"Ptr":"bla",` +
  166. `"PtrNil":null` +
  167. "}"
  168. type SubStruct struct {
  169. Value string
  170. Value2 string
  171. unexpored bool
  172. }
  173. type SubP struct {
  174. V string
  175. }
  176. type SubStructAlias SubStruct
  177. type Structs struct {
  178. SubStruct
  179. *SubP
  180. Value2 int
  181. Sub1 SubStruct `json:"substruct"`
  182. Sub2 *SubStruct
  183. SubNil *SubStruct
  184. SubSlice []SubStruct
  185. SubSliceNil []SubStruct
  186. SubPtrSlice []*SubStruct
  187. SubPtrSliceNil []*SubStruct
  188. SubA1 SubStructAlias
  189. SubA2 *SubStructAlias
  190. Anonymous struct {
  191. V string
  192. I int
  193. }
  194. Anonymous1 *struct {
  195. V string
  196. }
  197. AnonymousSlice []struct{ V int }
  198. AnonymousPtrSlice []*struct{ V int }
  199. Slice []string
  200. unexported bool
  201. }
  202. var structsValue = Structs{
  203. SubStruct: SubStruct{Value: "test"},
  204. SubP: &SubP{V: "subp"},
  205. Value2: 5,
  206. Sub1: SubStruct{Value: "test1", Value2: "v"},
  207. Sub2: &SubStruct{Value: "test2", Value2: "v2"},
  208. SubSlice: []SubStruct{
  209. {Value: "s1"},
  210. {Value: "s2"},
  211. },
  212. SubPtrSlice: []*SubStruct{
  213. {Value: "p1"},
  214. {Value: "p2"},
  215. },
  216. SubA1: SubStructAlias{Value: "test3", Value2: "v3"},
  217. SubA2: &SubStructAlias{Value: "test4", Value2: "v4"},
  218. Anonymous: struct {
  219. V string
  220. I int
  221. }{V: "bla", I: 5},
  222. Anonymous1: &struct {
  223. V string
  224. }{V: "bla1"},
  225. AnonymousSlice: []struct{ V int }{{1}, {2}},
  226. AnonymousPtrSlice: []*struct{ V int }{{3}, {4}},
  227. Slice: []string{"test5", "test6"},
  228. }
  229. var structsString = "{" +
  230. `"Value2":5,` +
  231. `"substruct":{"Value":"test1","Value2":"v"},` +
  232. `"Sub2":{"Value":"test2","Value2":"v2"},` +
  233. `"SubNil":null,` +
  234. `"SubSlice":[{"Value":"s1","Value2":""},{"Value":"s2","Value2":""}],` +
  235. `"SubSliceNil":null,` +
  236. `"SubPtrSlice":[{"Value":"p1","Value2":""},{"Value":"p2","Value2":""}],` +
  237. `"SubPtrSliceNil":null,` +
  238. `"SubA1":{"Value":"test3","Value2":"v3"},` +
  239. `"SubA2":{"Value":"test4","Value2":"v4"},` +
  240. `"Anonymous":{"V":"bla","I":5},` +
  241. `"Anonymous1":{"V":"bla1"},` +
  242. `"AnonymousSlice":[{"V":1},{"V":2}],` +
  243. `"AnonymousPtrSlice":[{"V":3},{"V":4}],` +
  244. `"Slice":["test5","test6"],` +
  245. // Embedded fields go last.
  246. `"V":"subp",` +
  247. `"Value":"test"` +
  248. "}"
  249. type OmitEmpty struct {
  250. // NOTE: first field is empty to test comma printing.
  251. StrE, StrNE string `json:",omitempty"`
  252. PtrE, PtrNE *string `json:",omitempty"`
  253. IntNE int `json:"intField,omitempty"`
  254. IntE int `json:",omitempty"`
  255. // NOTE: omitempty has no effect on non-pointer struct fields.
  256. SubE, SubNE SubStruct `json:",omitempty"`
  257. SubPE, SubPNE *SubStruct `json:",omitempty"`
  258. }
  259. var omitEmptyValue = OmitEmpty{
  260. StrNE: "str",
  261. PtrNE: &str,
  262. IntNE: 6,
  263. SubNE: SubStruct{Value: "1", Value2: "2"},
  264. SubPNE: &SubStruct{Value: "3", Value2: "4"},
  265. }
  266. var omitEmptyString = "{" +
  267. `"StrNE":"str",` +
  268. `"PtrNE":"bla",` +
  269. `"intField":6,` +
  270. `"SubE":{"Value":"","Value2":""},` +
  271. `"SubNE":{"Value":"1","Value2":"2"},` +
  272. `"SubPNE":{"Value":"3","Value2":"4"}` +
  273. "}"
  274. type Opts struct {
  275. StrNull opt.String
  276. StrEmpty opt.String
  277. Str opt.String
  278. StrOmitempty opt.String `json:",omitempty"`
  279. IntNull opt.Int
  280. IntZero opt.Int
  281. Int opt.Int
  282. }
  283. var optsValue = Opts{
  284. StrEmpty: opt.OString(""),
  285. Str: opt.OString("test"),
  286. IntZero: opt.OInt(0),
  287. Int: opt.OInt(5),
  288. }
  289. var optsString = `{` +
  290. `"StrNull":null,` +
  291. `"StrEmpty":"",` +
  292. `"Str":"test",` +
  293. `"IntNull":null,` +
  294. `"IntZero":0,` +
  295. `"Int":5` +
  296. `}`
  297. type Raw struct {
  298. Field easyjson.RawMessage
  299. Field2 string
  300. }
  301. var rawValue = Raw{
  302. Field: []byte(`{"a" : "b"}`),
  303. Field2: "test",
  304. }
  305. var rawString = `{` +
  306. `"Field":{"a" : "b"},` +
  307. `"Field2":"test"` +
  308. `}`
  309. type StdMarshaler struct {
  310. T time.Time
  311. IP net.IP
  312. }
  313. var stdMarshalerValue = StdMarshaler{
  314. T: time.Date(2016, 01, 02, 14, 15, 10, 0, time.UTC),
  315. IP: net.IPv4(192, 168, 0, 1),
  316. }
  317. var stdMarshalerString = `{` +
  318. `"T":"2016-01-02T14:15:10Z",` +
  319. `"IP":"192.168.0.1"` +
  320. `}`
  321. type UserMarshaler struct {
  322. V vMarshaler
  323. T tMarshaler
  324. }
  325. type vMarshaler net.IP
  326. func (v vMarshaler) MarshalJSON() ([]byte, error) {
  327. return []byte(`"0::0"`), nil
  328. }
  329. func (v *vMarshaler) UnmarshalJSON([]byte) error {
  330. *v = vMarshaler(net.IPv6zero)
  331. return nil
  332. }
  333. type tMarshaler net.IP
  334. func (v tMarshaler) MarshalText() ([]byte, error) {
  335. return []byte(`[0::0]`), nil
  336. }
  337. func (v *tMarshaler) UnmarshalText([]byte) error {
  338. *v = tMarshaler(net.IPv6zero)
  339. return nil
  340. }
  341. var userMarshalerValue = UserMarshaler{
  342. V: vMarshaler(net.IPv6zero),
  343. T: tMarshaler(net.IPv6zero),
  344. }
  345. var userMarshalerString = `{` +
  346. `"V":"0::0",` +
  347. `"T":"[0::0]"` +
  348. `}`
  349. type unexportedStruct struct {
  350. Value string
  351. }
  352. var unexportedStructValue = unexportedStruct{"test"}
  353. var unexportedStructString = `{"Value":"test"}`
  354. type ExcludedField struct {
  355. Process bool `json:"process"`
  356. DoNotProcess bool `json:"-"`
  357. DoNotProcess1 bool `json:"-"`
  358. }
  359. var excludedFieldValue = ExcludedField{
  360. Process: true,
  361. DoNotProcess: false,
  362. DoNotProcess1: false,
  363. }
  364. var excludedFieldString = `{"process":true}`
  365. type Slices struct {
  366. ByteSlice []byte
  367. EmptyByteSlice []byte
  368. NilByteSlice []byte
  369. IntSlice []int
  370. EmptyIntSlice []int
  371. NilIntSlice []int
  372. }
  373. var sliceValue = Slices{
  374. ByteSlice: []byte("abc"),
  375. EmptyByteSlice: []byte{},
  376. NilByteSlice: []byte(nil),
  377. IntSlice: []int{1, 2, 3, 4, 5},
  378. EmptyIntSlice: []int{},
  379. NilIntSlice: []int(nil),
  380. }
  381. var sliceString = `{` +
  382. `"ByteSlice":"YWJj",` +
  383. `"EmptyByteSlice":"",` +
  384. `"NilByteSlice":null,` +
  385. `"IntSlice":[1,2,3,4,5],` +
  386. `"EmptyIntSlice":[],` +
  387. `"NilIntSlice":null` +
  388. `}`
  389. type Arrays struct {
  390. ByteArray [3]byte
  391. EmptyByteArray [0]byte
  392. IntArray [5]int
  393. EmptyIntArray [0]int
  394. }
  395. var arrayValue = Arrays{
  396. ByteArray: [3]byte{'a', 'b', 'c'},
  397. EmptyByteArray: [0]byte{},
  398. IntArray: [5]int{1, 2, 3, 4, 5},
  399. EmptyIntArray: [0]int{},
  400. }
  401. var arrayString = `{` +
  402. `"ByteArray":"YWJj",` +
  403. `"EmptyByteArray":"",` +
  404. `"IntArray":[1,2,3,4,5],` +
  405. `"EmptyIntArray":[]` +
  406. `}`
  407. var arrayOverflowString = `{` +
  408. `"ByteArray":"YWJjbnNk",` +
  409. `"EmptyByteArray":"YWJj",` +
  410. `"IntArray":[1,2,3,4,5,6],` +
  411. `"EmptyIntArray":[7,8]` +
  412. `}`
  413. var arrayUnderflowValue = Arrays{
  414. ByteArray: [3]byte{'x', 0, 0},
  415. EmptyByteArray: [0]byte{},
  416. IntArray: [5]int{1, 2, 0, 0, 0},
  417. EmptyIntArray: [0]int{},
  418. }
  419. var arrayUnderflowString = `{` +
  420. `"ByteArray":"eA==",` +
  421. `"IntArray":[1,2]` +
  422. `}`
  423. type Str string
  424. type Maps struct {
  425. Map map[string]string
  426. InterfaceMap map[string]interface{}
  427. NilMap map[string]string
  428. CustomMap map[Str]Str
  429. }
  430. var mapsValue = Maps{
  431. Map: map[string]string{"A": "b"}, // only one item since map iteration is randomized
  432. InterfaceMap: map[string]interface{}{"G": float64(1)},
  433. CustomMap: map[Str]Str{"c": "d"},
  434. }
  435. var mapsString = `{` +
  436. `"Map":{"A":"b"},` +
  437. `"InterfaceMap":{"G":1},` +
  438. `"NilMap":null,` +
  439. `"CustomMap":{"c":"d"}` +
  440. `}`
  441. type NamedSlice []Str
  442. type NamedMap map[Str]Str
  443. type DeepNest struct {
  444. SliceMap map[Str][]Str
  445. SliceMap1 map[Str][]Str
  446. SliceMap2 map[Str][]Str
  447. NamedSliceMap map[Str]NamedSlice
  448. NamedMapMap map[Str]NamedMap
  449. MapSlice []map[Str]Str
  450. NamedSliceSlice []NamedSlice
  451. NamedMapSlice []NamedMap
  452. NamedStringSlice []NamedString
  453. }
  454. var deepNestValue = DeepNest{
  455. SliceMap: map[Str][]Str{
  456. "testSliceMap": []Str{
  457. "0",
  458. "1",
  459. },
  460. },
  461. SliceMap1: map[Str][]Str{
  462. "testSliceMap1": []Str(nil),
  463. },
  464. SliceMap2: map[Str][]Str{
  465. "testSliceMap2": []Str{},
  466. },
  467. NamedSliceMap: map[Str]NamedSlice{
  468. "testNamedSliceMap": NamedSlice{
  469. "2",
  470. "3",
  471. },
  472. },
  473. NamedMapMap: map[Str]NamedMap{
  474. "testNamedMapMap": NamedMap{
  475. "key1": "value1",
  476. },
  477. },
  478. MapSlice: []map[Str]Str{
  479. map[Str]Str{
  480. "testMapSlice": "someValue",
  481. },
  482. },
  483. NamedSliceSlice: []NamedSlice{
  484. NamedSlice{
  485. "someValue1",
  486. "someValue2",
  487. },
  488. NamedSlice{
  489. "someValue3",
  490. "someValue4",
  491. },
  492. },
  493. NamedMapSlice: []NamedMap{
  494. NamedMap{
  495. "key2": "value2",
  496. },
  497. NamedMap{
  498. "key3": "value3",
  499. },
  500. },
  501. NamedStringSlice: []NamedString{
  502. "value4", "value5",
  503. },
  504. }
  505. var deepNestString = `{` +
  506. `"SliceMap":{` +
  507. `"testSliceMap":["0","1"]` +
  508. `},` +
  509. `"SliceMap1":{` +
  510. `"testSliceMap1":null` +
  511. `},` +
  512. `"SliceMap2":{` +
  513. `"testSliceMap2":[]` +
  514. `},` +
  515. `"NamedSliceMap":{` +
  516. `"testNamedSliceMap":["2","3"]` +
  517. `},` +
  518. `"NamedMapMap":{` +
  519. `"testNamedMapMap":{"key1":"value1"}` +
  520. `},` +
  521. `"MapSlice":[` +
  522. `{"testMapSlice":"someValue"}` +
  523. `],` +
  524. `"NamedSliceSlice":[` +
  525. `["someValue1","someValue2"],` +
  526. `["someValue3","someValue4"]` +
  527. `],` +
  528. `"NamedMapSlice":[` +
  529. `{"key2":"value2"},` +
  530. `{"key3":"value3"}` +
  531. `],` +
  532. `"NamedStringSlice":["value4","value5"]` +
  533. `}`
  534. //easyjson:json
  535. type Ints []int
  536. var IntsValue = Ints{1, 2, 3, 4, 5}
  537. var IntsString = `[1,2,3,4,5]`
  538. //easyjson:json
  539. type MapStringString map[string]string
  540. var mapStringStringValue = MapStringString{"a": "b"}
  541. var mapStringStringString = `{"a":"b"}`
  542. type RequiredOptionalStruct struct {
  543. FirstName string `json:"first_name,required"`
  544. Lastname string `json:"last_name"`
  545. }
  546. type RequiredOptionalMap struct {
  547. ReqMap map[int]string `json:"req_map,required"`
  548. OmitEmptyMap map[int]string `json:"oe_map,omitempty"`
  549. NoOmitEmptyMap map[int]string `json:"noe_map,!omitempty"`
  550. }
  551. //easyjson:json
  552. type EncodingFlagsTestMap struct {
  553. F map[string]string
  554. }
  555. //easyjson:json
  556. type EncodingFlagsTestSlice struct {
  557. F []string
  558. }
  559. type StructWithInterface struct {
  560. Field1 int `json:"f1"`
  561. Field2 interface{} `json:"f2"`
  562. Field3 string `json:"f3"`
  563. }
  564. type EmbeddedStruct struct {
  565. Field1 int `json:"f1"`
  566. Field2 string `json:"f2"`
  567. }
  568. var structWithInterfaceString = `{"f1":1,"f2":{"f1":11,"f2":"22"},"f3":"3"}`
  569. var structWithInterfaceValueFilled = StructWithInterface{1, &EmbeddedStruct{11, "22"}, "3"}
  570. //easyjson:json
  571. type MapIntString map[int]string
  572. var mapIntStringValue = MapIntString{3: "hi"}
  573. var mapIntStringValueString = `{"3":"hi"}`
  574. //easyjson:json
  575. type MapInt32String map[int32]string
  576. var mapInt32StringValue = MapInt32String{-354634382: "life"}
  577. var mapInt32StringValueString = `{"-354634382":"life"}`
  578. //easyjson:json
  579. type MapInt64String map[int64]string
  580. var mapInt64StringValue = MapInt64String{-3546343826724305832: "life"}
  581. var mapInt64StringValueString = `{"-3546343826724305832":"life"}`
  582. //easyjson:json
  583. type MapUintString map[uint]string
  584. var mapUintStringValue = MapUintString{42: "life"}
  585. var mapUintStringValueString = `{"42":"life"}`
  586. //easyjson:json
  587. type MapUint32String map[uint32]string
  588. var mapUint32StringValue = MapUint32String{354634382: "life"}
  589. var mapUint32StringValueString = `{"354634382":"life"}`
  590. //easyjson:json
  591. type MapUint64String map[uint64]string
  592. var mapUint64StringValue = MapUint64String{3546343826724305832: "life"}
  593. var mapUint64StringValueString = `{"3546343826724305832":"life"}`
  594. //easyjson:json
  595. type MapUintptrString map[uintptr]string
  596. var mapUintptrStringValue = MapUintptrString{272679208: "obj"}
  597. var mapUintptrStringValueString = `{"272679208":"obj"}`
  598. type MyInt int
  599. //easyjson:json
  600. type MapMyIntString map[MyInt]string
  601. var mapMyIntStringValue = MapMyIntString{MyInt(42): "life"}
  602. var mapMyIntStringValueString = `{"42":"life"}`
  603. //easyjson:json
  604. type IntKeyedMapStruct struct {
  605. Foo MapMyIntString `json:"foo"`
  606. Bar map[int16]MapUint32String `json:"bar"`
  607. }
  608. var intKeyedMapStructValue = IntKeyedMapStruct{
  609. Foo: mapMyIntStringValue,
  610. Bar: map[int16]MapUint32String{32: mapUint32StringValue},
  611. }
  612. var intKeyedMapStructValueString = `{` +
  613. `"foo":{"42":"life"},` +
  614. `"bar":{"32":{"354634382":"life"}}` +
  615. `}`
  616. type IntArray [2]int
  617. //easyjson:json
  618. type IntArrayStruct struct {
  619. Pointer *IntArray `json:"pointer"`
  620. Value IntArray `json:"value"`
  621. }
  622. var intArrayStructValue = IntArrayStruct{
  623. Pointer: &IntArray{1, 2},
  624. Value: IntArray{1, 2},
  625. }
  626. var intArrayStructValueString = `{` +
  627. `"pointer":[1,2],` +
  628. `"value":[1,2]` +
  629. `}`
  630. type MyUInt8 uint8
  631. //easyjson:json
  632. type MyUInt8Slice []MyUInt8
  633. var myUInt8SliceValue = MyUInt8Slice{1, 2, 3, 4, 5}
  634. var myUInt8SliceString = `[1,2,3,4,5]`
  635. //easyjson:json
  636. type MyUInt8Array [2]MyUInt8
  637. var myUInt8ArrayValue = MyUInt8Array{1, 2}
  638. var myUInt8ArrayString = `[1,2]`