引入ffjson包
go get -u github.com/pquerna/ffjson
Import (
"github.com/pquerna/ffjson/ffjson"
)
// json测试
// 初始化数据
input := make(map[string]interface{})
input["status"] = 200
// json格式化
inputJson, _ := ffjson.Marshal(input)
// 输出
logging.Info(200, inputJson)
// [200 [123 34 115 116 97 116 117 115 34 58 50 48 48 125]]
logging.Info(200, string(inputJson[:]))
// {"status":200}
// json解析
inputDecode := make(map[string]interface{})
ffjson.Unmarshal(inputJson[:], &inputDecode)
// 输出
logging.Info(200, inputDecode)
// map[status:200]
网友评论