Last active
August 29, 2015 14:06
-
-
Save holys/fe6057cb6ccb8a1ce01f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
) | |
type Vip struct { | |
ExpireTime int `json:"expire_time"` | |
MemberId int `json:"memberid"` | |
HasAd int `json:"has_ad"` | |
Name string `json:"name"` | |
} | |
type User struct { | |
Wealth int `json:"wealth"` | |
TotalBuy int `json:"total_buy"` | |
Level int `json:"level"` | |
TotalCost int `json:"total_cost"` | |
UserId int `json:"userid"` | |
Vip Vip | |
Result string `json:"result"` | |
Exp int `json:"exp"` | |
Privilege Privilege | |
} | |
type Privilege struct { | |
} | |
func main() { | |
str := `{"level":1,"wealth":2,"total_cost":0,"result":"ok","exp":4,"total_buy":0,"vip":{"memberid":10,"has_ad":1,"name":"青铜会员","expire_time":1732970293},"userid":20134201,"privilege":{}} | |
` | |
var u User | |
// u := &User{} | |
json.Unmarshal([]byte(str), &u) | |
fmt.Println(u) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment