-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
61 lines (53 loc) · 1.09 KB
/
main.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
56
57
58
59
60
61
package main
import (
"encoding/json"
"fmt"
"github.com/astaxie/beego"
"github.com/bitly/go-simplejson" // for json get
// "goAPI/database"
_ "goAPI/docs"
// "goAPI/models"
_ "goAPI/routers"
)
type mapData struct {
Name string
}
type BaseData struct {
Msg string
Status float32
Result mapData
}
func main() {
// defer database.CloseDatabase()
// if beego.RunMode == "dev" {
// beego.DirectoryIndex = true
// beego.StaticDir["/swagger"] = "swagger"
// }
// u1 := models.User{Name: "hahah", Age: 24, Sex: 1, Tel: "15971470520"}
// account1 := models.AccountInfo{MemberId: "15071379972", Account: "15071379972", Password: "111111"}
// models.Insert(&account1)
// testJson()
beego.Run()
}
func testJson() {
var m1 mapData
var b1 BaseData
m1.Name = "ray"
b1.Msg = "success"
b1.Status = 0
b1.Result = m1
body, err := json.Marshal(b1)
if err != nil {
panic(err.Error())
}
fmt.Println("body:", string(body))
js, err := simplejson.NewJson(body)
if err != nil {
panic(err.Error())
}
maps, err1 := js.Map()
if err1 != nil {
fmt.Println(err)
}
fmt.Println(maps["Msg"])
}