What I am looking is equivalent of Document.parse()
in golang, that allows me create bson from json directly? I do not want to create intermediate Go structs for marshaling
What I am looking is equivalent of Document.parse()
in golang, that allows me create bson from json directly? I do not want to create intermediate Go structs for marshaling
The
gopkg.in/mgo.v2/bson
package has a function calledUnmarshalJSON
which does exactly what you want.The
data
parameter should hold you JSON string as[]byte
value.Example: