Created
July 15, 2016 12:18
-
-
Save yaoboss/884bf2cd41d6b37f46157db8c497896c to your computer and use it in GitHub Desktop.
Go json to map
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" | |
) | |
func main() { | |
arrayStr := `[ | |
{ | |
"id": "827", | |
"name": "开门红", | |
"url": "/fxstatic/images/giftres/827/18f003c2ff6b0b40191298bf54c7f0a1.swf", | |
"pic": "/fxstatic/images/giftres/827/252216feb8b4badc5c2fd02826ac171b.gif", | |
"price": "188", | |
"exchange": "94.0", | |
"category": "19", | |
"mix": "1", | |
"fly": "0", | |
"class": "\\Fx\\BLL\\Gift\\GiftTpl\\GiftTplBase", | |
"sortIndex": "0", | |
"status": "0", | |
"image": "/fxstatic/images/giftres/827/db342be840d40ce77751305864578339.png", | |
"isNew": "1", | |
"imageTrans": "/fxstatic/images/giftres/827/418bc7090e6e63ad6840ae7a3d0c8e6f.png", | |
"imageGrade": "/fxstatic/images/giftres/827/77feae9a54d02e15828916fd78c1dc33.png", | |
"expire": "0", | |
"richLevelLimit": "0", | |
"type": "0", | |
"adtEffect": "/fxstatic/images/giftres/827/827_1468312216.zip", | |
"guardLevelLimit": "-2", | |
"vipLimit": "0", | |
"isPile": "0", | |
"canNotSend": "0", | |
"extra": "[]", | |
"userIdLimit": "0", | |
"extraType": "0" | |
}, | |
{ | |
"id": "828", | |
"name": "金元宝", | |
"url": "/fxstatic/images/giftres/828/f385591b8395ec2b264a00dc704037b4.swf", | |
"pic": "/fxstatic/images/giftres/828/c2f5882e22d6cdef141cfa45500c6c17.gif", | |
"price": "1888", | |
"exchange": "944.0", | |
"category": "19", | |
"mix": "1", | |
"fly": "0", | |
"class": "\\Fx\\BLL\\Gift\\GiftTpl\\GiftTplBase", | |
"sortIndex": "0", | |
"status": "0", | |
"image": "/fxstatic/images/giftres/828/5044dbe705f61f3be1f0cd62c195bd33.png", | |
"isNew": "1", | |
"imageTrans": "/fxstatic/images/giftres/828/209104a5692375dcdcb0b3312c988461.png", | |
"imageGrade": "/fxstatic/images/giftres/828/8841eacefed173745f56c6ee1a1b3a00.png", | |
"expire": "0", | |
"richLevelLimit": "0", | |
"type": "0", | |
"adtEffect": "/fxstatic/images/giftres/828/828_1468312399.zip", | |
"guardLevelLimit": "-2", | |
"vipLimit": "0", | |
"isPile": "0", | |
"canNotSend": "0", | |
"extra": "[]", | |
"userIdLimit": "0", | |
"extraType": "0" | |
} | |
]` | |
var jsonMap []map[string]string | |
err := json.Unmarshal([]byte(arrayStr), &jsonMap) | |
if err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println(jsonMap) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment