This is a creation in Article, where the information may have evolved or changed.
Bson's introduction, I'm not talking.
Golang the parsing package found 2 a MONGO Http://labix.org/gobson
, another small crowd https://github.com/sbunce/bson
Here is an example of MONGO.
object with different annotations,
Can easily be turned into XML JSON Bson excited to think
1 Package Main2 3 Import (4 "FMT"5 "Labix.org/v2/mgo/bson"6 )7 8Type teststructstruct {9NamestringTen ID Int32 One } A - Func Main () { -Fmt. Println ("Start") theData, err: = Bson. Marshal (&teststruct{name:"Bob"}) - ifErr! =Nil { - Panic (Err) - } +Fmt. Println ("%q", data) - +Value: =teststruct{} AERR2: = Bson. Unmarshal (Data, &value) at ifErr2! =Nil { - Panic (Err) - } -Fmt. Println ("Value:", value) - -Mmap: =Bson. m{} inERR3: =Bson. Unmarshal (data, mmap) - ifErr3! =Nil { to Panic (Err) + } -Fmt. Println ("mmap:", Mmap) the}
Reprinted from Http://www.blogjava.net/oathleo/archive/2013/09/22/golang_bson_struct_mongo.html