agent/api/container/transitiondependency.go
func (td *TransitionDependenciesMap) UnmarshalJSON(b []byte) error {
	depMap := make(map[apicontainerstatus.ContainerStatus]TransitionDependencySet)
	err := json.Unmarshal(b, &depMap)
	if err == nil {
		*td = depMap
		return nil
	}
	seelog.Debugf("Unmarshal 'TransitionDependencySet': %s, not a map: %v", string(b), err)
	// Unmarshal to deprecated 'TransitionDependencySet' and then convert to a map
	tdSet := TransitionDependencySet{}
	if err := json.Unmarshal(b, &tdSet); err != nil {
		return errors.Wrapf(err,
			"Unmarshal 'TransitionDependencySet': does not comply with any of the dependency types")
	}
	for _, dep := range tdSet.ContainerDependencies {
		dependentStatus := dep.DependentStatus
		// no need for DependentStatus field anymore, since it becomes the map's key
		dep.DependentStatus = 0
		if _, ok := depMap[dependentStatus]; !ok {
			depMap[dependentStatus] = TransitionDependencySet{}
		}
		deps := depMap[dependentStatus]
		deps.ContainerDependencies = append(deps.ContainerDependencies, dep)
		depMap[dependentStatus] = deps
	}
	*td = depMap
	return nil
}
func (td *TransitionDependenciesMap) UnmarshalJSON(b []byte) error {
	depMap := make(map[apicontainerstatus.ContainerStatus]TransitionDependencySet)
	err := json.Unmarshal(b, &depMap)
	if err == nil {
		*td = depMap
		return nil
	}
	seelog.Debugf("Unmarshal 'TransitionDependencySet': %s, not a map: %v", string(b), err)
	// Unmarshal to deprecated 'TransitionDependencySet' and then convert to a map
	tdSet := TransitionDependencySet{}
	if err := json.Unmarshal(b, &tdSet); err != nil {
		return errors.Wrapf(err,
			"Unmarshal 'TransitionDependencySet': does not comply with any of the dependency types")
	}
	for _, dep := range tdSet.ContainerDependencies {
		dependentStatus := dep.DependentStatus
		// no need for DependentStatus field anymore, since it becomes the map's key
		dep.DependentStatus = 0
		if _, ok := depMap[dependentStatus]; !ok {
			depMap[dependentStatus] = TransitionDependencySet{}
		}
		deps := depMap[dependentStatus]
		deps.ContainerDependencies = append(deps.ContainerDependencies, dep)
		depMap[dependentStatus] = deps
	}
	*td = depMap
	return nil
}
// UnmarshalJSON decodes the TransitionDependencySet tag in the JSON encoded string
// into the TransitionDependenciesMap object