Example #1
0
// MarshalJSON implements json.Marshaler for Leg. This encodes Go types back to
// the API representation.
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)
}
Example #2
0
// MarshalJSON implements json.Marshaler for Step. This encodes Go types back to
// the API representation.
func (step *Step) MarshalJSON() ([]byte, error) {
	x := encodedStep{}
	x.safeStep = safeStep(*step)

	x.EncDuration = internal.NewDuration(step.Duration)

	return json.Marshal(x)
}
Example #3
0
// MarshalJSON implements json.Marshaler for DistanceMatrixElement. This encodes
// Go types back to the API representation.
func (dme *DistanceMatrixElement) MarshalJSON() ([]byte, error) {
	x := encodedDistanceMatrixElement{}
	x.safeDistanceMatrixElement = safeDistanceMatrixElement(*dme)

	x.EncDuration = internal.NewDuration(dme.Duration)

	return json.Marshal(x)
}