dongzhiyan5693 2016-01-19 17:01
浏览 360
已采纳

将字节数组设置为json.RawMessage

I have array of bytes in golang:

obj_data, _ := json.Marshal(obj)

And a want set this array of bytes into json.RawMessage I thought that it would work:

data := json.RawMessage{obj_data}

but i have error:

cannot use obj_data (type []byte) as type byte in array element

please help me! =)

  • 写回答

1条回答 默认 最新

  • dongmeixi5311 2016-01-19 17:03
    关注

    You need a type conversion, not a literal:

    data := json.RawMessage(obj_data)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?