Custom struct type unmarshal

Hi @Philidor_Green,

One thing I notice in your example is that UnmarshalBSON internally calls bson.Unmarshal(data, &m) rather than bson.Unmarshal(data, &r). The next line tries to print out the contents of r, but it’s only been set to the zero-value in the variable declaration, so it will be an empty string.

Can you provide some example input/output to show your desired data format? We can help you write Marshal/Unmarshal implementations to do that.

– Divjot

1 Like