小编kis*_*ish的帖子

interface{} to []byte conversion in golang

I am trying to unmarshal a data which is of type interface. So I need to convert the interface type to []byte and pass it to unmarshall. i tried

  1. err := json.Unmarshal([]byte(kpi), &a) => failed
  2. i tired to convert the interface to byte by using kpidata, res := kpi.([]byte) => failed, kpidata is nil

So is there any way we can convert it?

Example: https://play.golang.org/p/5pqQ0DQ94Dp

json go

12
推荐指数
2
解决办法
2万
查看次数

标签 统计

go ×1

json ×1