我读了很多相关的问题,但找不到任何真正适合我的问题。我正试图解开一个复杂的物体。

type DC struct {

    //other fields
    ReplenishmentData map[string]ProductReplenishment `bson:"-"`
    //other fields
}

type ProductReplenishment struct {
    //Other fields
    SafetyStockInDay int `json:"SafetyStockInDay" bson:"SafetyStockInDay"`
    AlreadyOrderedQuantityForReplenishment *map[float64]*UnitQuantity `json:"-" bson:"-"`
    //Other fields
}

假设我解码以下json:

{
  "ReplenishmentData": {
    "000822-099": {
      "SafetyStockInDay": 7
    },
    "001030-001": {
      "SafetyStockInDay": 7
    }
  }
}

在结构实例层次结构中,alreadyOrderedQuantityForRequiremency不为空,解码后该字段将被设置为和空映射,覆盖初始值。

为什么解码器不忽略文档中指定的所有字段?我遗漏了什么吗?

非常感谢你的帮助,

在(第一个)之前/之后(第二个)添加检查员的屏幕截图(如果有帮助的话)

before after