code: func (g Geometry) MarshalJSON() ([]byte, error) {
  	// defining a struct here lets us define the order of the JSON elements.
  	type geometry struct {
  		Type        GeometryType           `json:"type"`
  		BoundingBox []float64              `json:"bbox,omitempty"`
  		Coordinates interface{}            `json:"coordinates,omitempty"`
  		Geometries  interface{}            `json:"geometries,omitempty"`
  		CRS         map[string]interface{} `json:"crs,omitempty"`
  	}
  
  	geo := &geometry{
  		Type: g.Type,
  	}
  
  	if g.BoundingBox != nil && len(g.BoundingBox) != 0 {
  		geo.BoundingBox = g.BoundingBox
  	}
  
  	switch g.Type {
  	case GeometryPoint:
  		geo.Coordinates = g.Point
  	case GeometryMultiPoint:
  		geo.Coordinates = g.MultiPoint
  	case GeometryLineString:
  		geo.Coordinates = g.LineString
  	case GeometryMultiLineString:
  		geo.Coordinates = g.MultiLineString
  	case GeometryPolygon:
  		geo.Coordinates = g.Polygon
  	case GeometryMultiPolygon:
  		geo.Coordinates = g.MultiPolygon
  	case GeometryCollection:
  		geo.Geometries = g.Geometries
  	}
  
  	return json.Marshal(geo)
  }
docs: // MarshalJSON converts the geometry object into the correct JSON.
  // This fulfills the json.Marshaler interface.