An open API service indexing awesome lists of open source software.

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.

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))

```