Description

Unmarshal deserializes data from in into the out value. The out value must be a map, a pointer to a struct, or a pointer to a bson.D value. The lowercased field name is used as the key for each exported field, but this behavior may be changed using the respective field tag. The tag may also contain flags to tweak the marshalling behavior for the field. The tag formats accepted are:

"[<key>][,<flag1>[,<flag2>]]"

`(...) bson:"[<key>][,<flag1>[,<flag2>]]" (...)`

The following flags are currently supported during unmarshal (see the Marshal method for other flags):

inline     Inline the field, which must be a struct or a map.
           Inlined structs are handled as if its fields were part
           of the outer struct. An inlined map causes keys that do
           not match any other struct field to be inserted in the
           map rather than being discarded as usual.

The target field or element types of out may not necessarily match the BSON values of the provided data. The following conversions are made automatically:

- Numeric types are converted if at least the integer part of the

value would be preserved correctly

- Bools are converted to numeric types as 1 or 0 - Numeric types are converted to bools as true if not 0 or false otherwise - Binary and string BSON data is converted to a string, array or byte slice

If the value would not fit the type and cannot be converted, it's silently skipped.

Pointer values are initialized when necessary.

Unmarshal is referenced in 0 repositories