1
2
17
18 package testdata
19
20
21
22 type Book struct {
23 BookId int `json:"id"`
24 BookIds []int `json:"ids"`
25 Title string `json:"title"`
26 Titles []string `json:"titles"`
27 Price float64 `json:"price"`
28 Prices []float64 `json:"prices"`
29 Hot bool `json:"hot"`
30 Hots []bool `json:"hots"`
31 Author Author `json:"author"`
32 Authors []Author `json:"authors"`
33 Weights []int `json:"weights"`
34 }
35
36
37
38 type Author struct {
39 Name string `json:"name"`
40 Age int `json:"age"`
41 Male bool `json:"male"`
42 }
43
44 var book = Book{
45 BookId: 12125925,
46 BookIds: []int{-2147483648, 2147483647},
47 Title: "未来简史-从智人到智神",
48 Titles: []string{"hello", "world"},
49 Price: 40.8,
50 Prices: []float64{-0.1, 0.1},
51 Hot: true,
52 Hots: []bool{true, true, true},
53 Author: author,
54 Authors: []Author{author, author, author},
55 Weights: nil,
56 }
57
58 var author = Author{
59 Name: "json",
60 Age: 99,
61 Male: true,
62 }
63
64 var data = []byte(`{"id":12125925,"ids":[-2147483648,2147483647],"title":"未来简史-从智人到智神","titles":["hello","world"],"price":40.8,"prices":[-0.1,0.1],"hot":true,"hots":[true,true,true],"author":{"name":"json","age":99,"male":true},"authors":[{"name":"json","age":99,"male":true},{"name":"json","age":99,"male":true},{"name":"json","age":99,"male":true}],"weights":[]}`)
View as plain text