Assuming you have a channel ch
that receives the binary JSON message, you can use the encoding/json
package to unmarshal the binary data into a Go struct.
main.go238 chars16 lines
In the example above, a struct Message
is defined to represent the structure of the JSON data. The binary data is read from the channel and unmarshalled into an instance of Message
. If the unmarshalling fails, the error should be handled appropriately.
gistlibby LogSnag