golang simplejson 使用笔记

来源:互联网 发布:缓存数据库 编辑:程序博客网 时间:2024/05/21 17:12
第一步,得到json的内容
contents, _ := ioutil.ReadAll(res.Body)
js, js_err := simplejson.NewJson(contents)

第二部,根据json的格式,选择使用array或者map储存数据
var nodes = make(map[string]interface{})
nodes, _ = js.Map()

第三步,将nodes当作map处理即可,如果map的value仍是一个json机构,回到第二步。
for key,_ := range nodes {
...
}
0 0
原创粉丝点击