github.com/goshafaq/sonic@v0.0.0-20231026082336-871835fb94c6/testdata/small.go (about)

     1  /*
     2   * Copyright 2021 ByteDance Inc.
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  package testdata
    18  
    19  // ffjson: skip
    20  // easyjson:skip
    21  type Book struct {
    22  	BookId  int       `json:"id"`
    23  	BookIds []int     `json:"ids"`
    24  	Title   string    `json:"title"`
    25  	Titles  []string  `json:"titles"`
    26  	Price   float64   `json:"price"`
    27  	Prices  []float64 `json:"prices"`
    28  	Hot     bool      `json:"hot"`
    29  	Hots    []bool    `json:"hots"`
    30  	Author  Author    `json:"author"`
    31  	Authors []Author  `json:"authors"`
    32  	Weights []int     `json:"weights"`
    33  }
    34  
    35  // ffjson: skip
    36  // easyjson:skip
    37  type Author struct {
    38  	Name string `json:"name"`
    39  	Age  int    `json:"age"`
    40  	Male bool   `json:"male"`
    41  }
    42  
    43  var book = Book{
    44  	BookId:  12125925,
    45  	BookIds: []int{-2147483648, 2147483647},
    46  	Title:   "未来简史-从智人到智神",
    47  	Titles:  []string{"hello", "world"},
    48  	Price:   40.8,
    49  	Prices:  []float64{-0.1, 0.1},
    50  	Hot:     true,
    51  	Hots:    []bool{true, true, true},
    52  	Author:  author,
    53  	Authors: []Author{author, author, author},
    54  	Weights: nil,
    55  }
    56  
    57  var author = Author{
    58  	Name: "json",
    59  	Age:  99,
    60  	Male: true,
    61  }
    62  
    63  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":[]}`)