func (x *Binary) UnmarshalJSON(data []byte) (err error) {
	x2 := binary{}
	if err = json.Unmarshal(data, &x2); err == nil {
		*x = Binary(x2)
		return x.checkResourceType()
	}
	return
}
Custom unmarshaller to properly unmarshal embedded resources (represented as interface{})
package models
import (
	"encoding/json"
	"errors"
	"fmt"
)
type Binary struct {
	Resource    `bson:",inline"`
	ContentType string `bson:"contentType,omitempty" json:"contentType,omitempty"`
	Content     string `bson:"content,omitempty" json:"content,omitempty"`
}
func (resource *Binary) MarshalJSON() ([]byte, error) {
	resource.ResourceType = "Binary"
	return json.Marshal(*resource)
}
func (x *Binary) GetBSON() (interface{}, error) {
	x.ResourceType = "Binary"
	return *x, nil
}
type binary Binary