go JSON

package utils

import (
"encoding/json"
"errors"
) func JsonToMap(text []byte) (map[string]interface{}, error) { var anonymous interface{}
err := json.Unmarshal(text, &anonymous)
if err != nil {
return nil, errors.New(err.Error())
}
res := anonymous.(map[string]interface{}) return res, nil
}

参考:https://github.com/astaxie/build-web-application-with-golang/blob/master/zh/07.2.md

上一篇:Openstack运维指南文档整理


下一篇:Mac+sublime text+skim