func (sp *SnappedPoint) UnmarshalJSON(data []byte) error {
	x := encodedSnappedPoint{}
	err := json.Unmarshal(data, &x)
	if err != nil {
		return err
	}
	*sp = SnappedPoint(x.safeSnappedPoint)
	sp.Location.Lat = x.EncLocation.Latitude
	sp.Location.Lng = x.EncLocation.Longitude
	return nil
}
UnmarshalJSON implements json.Unmarshaler for SnappedPoint. This decode the
API representation into types useful for Go developers.
package maps
import (
	"encoding/json"
	"net/url"
	"googlemaps.github.io/maps/internal"
)
type safeLeg Leg
type encodedLeg struct {
	safeLeg
	EncDuration          *internal.Duration `json:"duration"`
	EncDurationInTraffic *internal.Duration `json:"duration_in_traffic"`
	EncArrivalTime       *internal.DateTime `json:"arrival_time"`
	EncDepartureTime     *internal.DateTime `json:"departure_time"`
}
func (leg *Leg) UnmarshalJSON(data []byte) error {
	x := encodedLeg{}
	err := json.Unmarshal(data, &x)
	if err != nil {
		return err
	}
	*leg = Leg(x.safeLeg)
	leg.Duration = x.EncDuration.Duration()
	leg.DurationInTraffic = x.EncDurationInTraffic.Duration()
	leg.ArrivalTime = x.EncArrivalTime.Time()
	leg.DepartureTime = x.EncDepartureTime.Time()
	return nil
}
func (leg *Leg) MarshalJSON() ([]byte, error) {
	x := encodedLeg{}
	x.safeLeg = safeLeg(*leg)
	x.EncDuration = internal.NewDuration(leg.Duration)
	x.EncDurationInTraffic = internal.NewDuration(leg.DurationInTraffic)
	x.EncArrivalTime = internal.NewDateTime(leg.ArrivalTime)
	x.EncDepartureTime = internal.NewDateTime(leg.DepartureTime)
	return json.Marshal(x)
}
type safeStep Step
type encodedStep struct {
	safeStep
	EncDuration *internal.Duration `json:"duration"`
}
func (step *Step) UnmarshalJSON(data []byte) error {
	x := encodedStep{}
	err := json.Unmarshal(data, &x)
	if err != nil {
		return err
	}
	*step = Step(x.safeStep)
	step.Duration = x.EncDuration.Duration()
	return nil
}
func (step *Step) MarshalJSON() ([]byte, error) {
	x := encodedStep{}
	x.safeStep = safeStep(*step)
	x.EncDuration = internal.NewDuration(step.Duration)
	return json.Marshal(x)
}
type safeTransitDetails TransitDetails
type encodedTransitDetails struct {
	safeTransitDetails
	EncArrivalTime   *internal.DateTime `json:"arrival_time"`
	EncDepartureTime *internal.DateTime `json:"departure_time"`
}
func (transitDetails *TransitDetails) UnmarshalJSON(data []byte) error {
	x := encodedTransitDetails{}
	err := json.Unmarshal(data, &x)
	if err != nil {
		return err
	}
	*transitDetails = TransitDetails(x.safeTransitDetails)
	transitDetails.ArrivalTime = x.EncArrivalTime.Time()
	transitDetails.DepartureTime = x.EncDepartureTime.Time()
	return nil
}
func (transitDetails *TransitDetails) MarshalJSON() ([]byte, error) {
	x := encodedTransitDetails{}
	x.safeTransitDetails = safeTransitDetails(*transitDetails)
	x.EncArrivalTime = internal.NewDateTime(transitDetails.ArrivalTime)
	x.EncDepartureTime = internal.NewDateTime(transitDetails.DepartureTime)
	return json.Marshal(x)
}
type safeTransitLine TransitLine
type encodedTransitLine struct {
	safeTransitLine
	EncURL  string `json:"url"`
	EncIcon string `json:"icon"`
}
func (transitLine *TransitLine) UnmarshalJSON(data []byte) error {
	x := encodedTransitLine{}
	err := json.Unmarshal(data, &x)
	if err != nil {
		return err
	}
	*transitLine = TransitLine(x.safeTransitLine)
	transitLine.URL, err = url.Parse(x.EncURL)
	if err != nil {
		return err
	}
	transitLine.Icon, err = url.Parse(x.EncIcon)
	if err != nil {
		return err
	}
	return nil
}
func (transitLine *TransitLine) MarshalJSON() ([]byte, error) {
	x := encodedTransitLine{}
	x.safeTransitLine = safeTransitLine(*transitLine)
	x.EncURL = transitLine.URL.String()
	x.EncIcon = transitLine.Icon.String()
	return json.Marshal(x)
}
type safeTransitAgency TransitAgency
type encodedTransitAgency struct {
	safeTransitAgency
	EncURL string `json:"url"`
}
func (transitAgency *TransitAgency) UnmarshalJSON(data []byte) error {
	x := encodedTransitAgency{}
	err := json.Unmarshal(data, &x)
	if err != nil {
		return err
	}
	*transitAgency = TransitAgency(x.safeTransitAgency)
	transitAgency.URL, err = url.Parse(x.EncURL)
	if err != nil {
		return err
	}
	return nil
}
func (transitAgency *TransitAgency) MarshalJSON() ([]byte, error) {
	x := encodedTransitAgency{}
	x.safeTransitAgency = safeTransitAgency(*transitAgency)
	x.EncURL = transitAgency.URL.String()
	return json.Marshal(x)
}
type safeTransitLineVehicle TransitLineVehicle
type encodedTransitLineVehicle struct {
	safeTransitLineVehicle
	EncIcon string `json:"icon"`
}
func (transitLineVehicle *TransitLineVehicle) UnmarshalJSON(data []byte) error {
	x := encodedTransitLineVehicle{}
	err := json.Unmarshal(data, &x)
	if err != nil {
		return err
	}
	*transitLineVehicle = TransitLineVehicle(x.safeTransitLineVehicle)
	transitLineVehicle.Icon, err = url.Parse(x.EncIcon)
	if err != nil {
		return err
	}
	return nil
}
func (transitLineVehicle *TransitLineVehicle) MarshalJSON() ([]byte, error) {
	x := encodedTransitLineVehicle{}
	x.safeTransitLineVehicle = safeTransitLineVehicle(*transitLineVehicle)
	x.EncIcon = transitLineVehicle.Icon.String()
	return json.Marshal(x)
}
type safeDistanceMatrixElement DistanceMatrixElement
type encodedDistanceMatrixElement struct {
	safeDistanceMatrixElement
	EncDuration          *internal.Duration `json:"duration"`
	EncDurationInTraffic *internal.Duration `json:"duration_in_traffic"`
}
func (dme *DistanceMatrixElement) UnmarshalJSON(data []byte) error {
	x := encodedDistanceMatrixElement{}
	err := json.Unmarshal(data, &x)
	if err != nil {
		return err
	}
	*dme = DistanceMatrixElement(x.safeDistanceMatrixElement)
	dme.Duration = x.EncDuration.Duration()
	dme.DurationInTraffic = x.EncDurationInTraffic.Duration()
	return nil
}
func (dme *DistanceMatrixElement) MarshalJSON() ([]byte, error) {
	x := encodedDistanceMatrixElement{}
	x.safeDistanceMatrixElement = safeDistanceMatrixElement(*dme)
	x.EncDuration = internal.NewDuration(dme.Duration)
	return json.Marshal(x)
}
type safeSnappedPoint SnappedPoint
type encodedSnappedPoint struct {
	safeSnappedPoint
	EncLocation internal.Location `json:"location"`
}