https://github.com/foolin/gomap
gomap for map[string]interface{} convert to base type.
https://github.com/foolin/gomap
Last synced: 5 days ago
JSON representation
gomap for map[string]interface{} convert to base type.
- Host: GitHub
- URL: https://github.com/foolin/gomap
- Owner: foolin
- Created: 2016-06-14T07:41:37.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-18T07:39:40.000Z (almost 10 years ago)
- Last Synced: 2025-08-13T20:13:41.316Z (11 months ago)
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
"# gomap"
type StrMap map[string]interface{}
include get base type method.
```go
jstr := `
{"userId":123,"name":"Forin", "sex": "2", "createTime":"2016-06-14T14:54:18.6492677+08:00","ext":{"son":"Tigo","Age":2}}
`
user := gomap.NewMapx()
err := json.Unmarshal([]byte(jstr), &user)
if err != nil {
log.Printf("json error: %v", err)
return
}
log.Printf("\n===================\n%#v\n ", user)
log.Printf("\n===================\next son:%#v\n ", user.Mapx("ext").String("son"))
log.Printf("\n===================\nUserId:%v\n ", user.Int("userId", 0))
```