func (x *Media) UnmarshalJSON(data []byte) (err error) {
	x2 := media{}
	if err = json.Unmarshal(data, &x2); err == nil {
		if x2.Contained != nil {
			for i := range x2.Contained {
				x2.Contained[i] = MapToResource(x2.Contained[i], true)
			}
		}
		*x = Media(x2)
		return x.checkResourceType()
	}
	return
}
Custom unmarshaller to properly unmarshal embedded resources (represented as interface{})
package models
import (
	"encoding/json"
	"errors"
	"fmt"
)
type Media struct {
	DomainResource `bson:",inline"`
	Identifier     []Identifier     `bson:"identifier,omitempty" json:"identifier,omitempty"`
	Type           string           `bson:"type,omitempty" json:"type,omitempty"`
	Subtype        *CodeableConcept `bson:"subtype,omitempty" json:"subtype,omitempty"`
	View           *CodeableConcept `bson:"view,omitempty" json:"view,omitempty"`
	Subject        *Reference       `bson:"subject,omitempty" json:"subject,omitempty"`
	Operator       *Reference       `bson:"operator,omitempty" json:"operator,omitempty"`
	DeviceName     string           `bson:"deviceName,omitempty" json:"deviceName,omitempty"`
	Height         *uint32          `bson:"height,omitempty" json:"height,omitempty"`
	Width          *uint32          `bson:"width,omitempty" json:"width,omitempty"`
	Frames         *uint32          `bson:"frames,omitempty" json:"frames,omitempty"`
	Duration       *uint32          `bson:"duration,omitempty" json:"duration,omitempty"`
	Content        *Attachment      `bson:"content,omitempty" json:"content,omitempty"`
}
func (resource *Media) MarshalJSON() ([]byte, error) {
	resource.ResourceType = "Media"
	return json.Marshal(*resource)
}
func (x *Media) GetBSON() (interface{}, error) {
	x.ResourceType = "Media"
	return *x, nil
}
type media Media