func (transitAgency *TransitAgency) MarshalJSON() ([]byte, error) {
	x := encodedTransitAgency{}
	x.safeTransitAgency = safeTransitAgency(*transitAgency)
	x.EncURL = transitAgency.URL.String()
	return json.Marshal(x)
}
MarshalJSON implements json.Marshaler for TransitAgency. This encodes Go
types back to the API representation.
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
}