Mgo - problem with struct imbricate


i have a problem with struct imbricate. i have a structure like that :

“_id” : ObjectId(“5b6982c0fa433a2278b6956d”),
“niveau” : “-1”,
“name” : {
“nom” : “Toto”,
“prenom” : “test”

and i defined my struct like :

type Personne struct {
Id bson.ObjectId bson:"_id"
Niveau string json:"niveau" bson:"niveau"
Name struct {
nom string json:"nom" bson:"nom"
prenom string
} json:"name" bson:"name"

but impossible to get all values … i’m sure that will be resolved by a little thing but i don’t succed

To make it work all fields that you want to unmarshal from the bson needs to be exposed, that means start with an uppercase letter.

1 Like

:pensive: ok, it’s well that … i didn’t see this fields. Thanks !

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.