-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson_test.go
55 lines (40 loc) · 1.05 KB
/
json_test.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
// Copyright 2021 Hollson. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package gdk
import (
"fmt"
"testing"
"time"
)
// https://blog.csdn.net/Gusand/article/details/99083259
type Optionals struct {
Sr string `json:"sr"`
So string `json:"so,omitempty"`
Sw string `json:"-"`
Ir int `json:"omitempty"` // actually named omitempty, not an option
Io int `json:"io,omitempty"`
Slr []string `json:"slr,random"`
Slo []string `json:"slo,omitempty"`
Mr map[string]interface{} `json:"mr"`
Mo map[string]interface{} `json:",omitempty"`
Fr float64 `json:"fr"`
Fo float64 `json:"fo,omitempty"`
Br bool `json:"br"`
Bo bool `json:"bo,omitempty"`
Ur uint `json:"ur"`
Uo uint `json:"uo,omitempty"`
Str struct{} `json:"str"`
Sto struct{} `json:"sto,omitempty"`
Dt JsonTime `json:"date"`
}
var obj = Optionals{
Io: 999,
Dt: JsonTime(time.Now()),
}
func TestJsonDump(t *testing.T) {
fmt.Println(Json(obj))
}
func TestPrettyJsonDump(t *testing.T) {
fmt.Println(JsonPretty(obj))
}