Encoding

BSON is a format made for documents/entities; therefore, the data structure used for encoding and decoding should be a structure or a map, but not a slice or an array. The mgo version of bson does not offer the usual encoder but only the marshal:

var char = Character{
Name: "Robert",
Surname: "Olmstead",
}
b, err := bson.Marshal(char)
if err != nil {
log.Fatalln(err)
}
log.Printf("%q", b)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.144.170