// ToGeoJSON creates a new geojson feature with a point geometry.
347676
func (p Point) ToGeoJSON() *geojson.Feature {
	return geojson.NewPointFeature([]float64{p[0], p[1]})
}
603008
func ToJSON(caddyfile []byte) ([]byte, error) {
	var j EncodedCaddyfile

	serverBlocks, err := Parse(filename, bytes.NewReader(caddyfile), nil)
	if err != nil {
		return nil, err
	}

	for _, sb := range serverBlocks {
		block := EncodedServerBlock{
			Keys: sb.Keys,
			Body: [][]interface{}{},
		}

		// Extract directives deterministically by sorting them
		var directives = make([]string, len(sb.Tokens))
		for dir := range sb.Tokens {
			directives = append(directives, dir)
		}
		sort.Strings(directives)

		// Convert each directive's tokens into our JSON structure
		for _, dir := range directives {
			disp := NewDispenserTokens(filename, sb.Tokens[dir])
			for disp.Next() {
				block.Body = append(block.Body, constructLine(&disp))
			}
		}

		// tack this block onto the end of the list
		j = append(j, block)
	}

	result, err := json.Marshal(j)
	if err != nil {
		return nil, err
	}

	return result, nil
}
12588
func (r *Resp) ToJSON(v interface{}) error {
	data, err := r.ToBytes()
	if err != nil {
		return err
	}
	return json.Unmarshal(data, v)
}
736934
func (point Point) Map() map[string]interface{} {
	result := make(map[string]interface{})
	result[COORDINATES] = point.Coordinates
	result[TYPE] = POINT
	return result
}
418797
func (p *Point) MarshalJSON() ([]byte, error) {
	res := fmt.Sprintf(`{"lat":%v, "lng":%v}`, p.lat, p.lng)
	return []byte(res), nil
}
208923
func (a Aggregations) GeoCentroid(name string) (*AggregationGeoCentroidMetric, bool) {
	if raw, found := a[name]; found {
		agg := new(AggregationGeoCentroidMetric)
		if raw == nil {
			return agg, true
		}
		if err := json.Unmarshal(raw, agg); err == nil {
			return agg, true
		}
	}
	return nil, false
}
1133136
func (fc *FeatureCollection) UnmarshalJSON(data []byte) error {
	var gfc geojsonFeatureCollection
	if err := json.Unmarshal(data, &gfc); err != nil {
		return err
	}
	if gfc.Type != "FeatureCollection" {
		return ErrUnsupportedType(gfc.Type)
	}
	fc.Features = gfc.Features
	return nil
}
501668
func (m Map) JSON() (string, error) {
	for k, v := range m {
		m[k] = cleanUp(v)
	}

	result, err := json.Marshal(m)
	if err != nil {
		err = errors.New("objx: JSON encode failed with: " + err.Error())
	}
	return string(result), err
}
1134576
func ToBsonMap(fields ...string) (selBson bson.M) {
	selBson = make(bson.M, len(fields))
	for _, s := range fields {
		selBson[s] = 1
	}
	return
}
1199587
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)
}
1184935
func ToJson(v interface{}) string { // nolint
	data, err := json.Marshal(v)
	if err != nil {
		// Swallow errors inside of a template.
		return ""
	}
	return string(data)
}
423574
func (g *Geometry) Decode() (geom.T, error) {
	switch g.Type {
	case "Point":
		if g.Coordinates == nil {
			return geom.NewPoint(geom.NoLayout), nil
		}
		var coords geom.Coord
		if err := json.Unmarshal(*g.Coordinates, &coords); err != nil {
			return nil, err
		}
		layout, err := guessLayout0(coords)
		if err != nil {
			return nil, err
		}
		return geom.NewPoint(layout).SetCoords(coords)
	case "LineString":
		if g.Coordinates == nil {
			return geom.NewLineString(geom.NoLayout), nil
		}
		var coords []geom.Coord
		if err := json.Unmarshal(*g.Coordinates, &coords); err != nil {
			return nil, err
		}
		layout, err := guessLayout1(coords)
		if err != nil {
			return nil, err
		}
		return geom.NewLineString(layout).SetCoords(coords)
	case "Polygon":
		if g.Coordinates == nil {
			return geom.NewPolygon(geom.NoLayout), nil
		}
		var coords [][]geom.Coord
		if err := json.Unmarshal(*g.Coordinates, &coords); err != nil {
			return nil, err
		}
		layout, err := guessLayout2(coords)
		if err != nil {
			return nil, err
		}
		return geom.NewPolygon(layout).SetCoords(coords)
	case "MultiPoint":
		if g.Coordinates == nil {
			return geom.NewMultiPoint(geom.NoLayout), nil
		}
		var coords []geom.Coord
		if err := json.Unmarshal(*g.Coordinates, &coords); err != nil {
			return nil, err
		}
		layout, err := guessLayout1(coords)
		if err != nil {
			return nil, err
		}
		return geom.NewMultiPoint(layout).SetCoords(coords)
	case "MultiLineString":
		if g.Coordinates == nil {
			return geom.NewMultiLineString(geom.NoLayout), nil
		}
		var coords [][]geom.Coord
		if err := json.Unmarshal(*g.Coordinates, &coords); err != nil {
			return nil, err
		}
		layout, err := guessLayout2(coords)
		if err != nil {
			return nil, err
		}
		return geom.NewMultiLineString(layout).SetCoords(coords)
	case "MultiPolygon":
		if g.Coordinates == nil {
			return geom.NewMultiPolygon(geom.NoLayout), nil
		}
		var coords [][][]geom.Coord
		if err := json.Unmarshal(*g.Coordinates, &coords); err != nil {
			return nil, err
		}
		layout, err := guessLayout3(coords)
		if err != nil {
			return nil, err
		}
		return geom.NewMultiPolygon(layout).SetCoords(coords)
	case "GeometryCollection":
		geoms := make([]geom.T, len(g.Geometries))
		for i, subGeometry := range g.Geometries {
			var err error
			geoms[i], err = subGeometry.Decode()
			if err != nil {
				return nil, err
			}
		}
		gc := geom.NewGeometryCollection()
		if err := gc.Push(geoms...); err != nil {
			return nil, err
		}
		return gc, nil
	default:
		return nil, ErrUnsupportedType(g.Type)
	}
}
1335480
func (t *Point) AddGeometry(g interface{}) error {
	if c, ok := g.(Coordinate); ok {
		t.Coordinates = c
	} else {
		return fmt.Errorf("AssertionError: %v to %v", g, "Coordinate")
	}
	return nil
}
121973
func (g *Geometry) Geometry(n int) (*Geometry, error) {
	// According to GEOS C API, GEOSGetGeometryN returns a pointer to internal
	// storage and must not be destroyed directly, so we bypass the regular
	// constructor to avoid the finalizer.
	return geomFromPtrUnowned(cGEOSGetGeometryN(g.g, C.int(n)))
}
407614
func NewFeature(geometry *Geometry) *Feature {
	return &Feature{
		Type:       "Feature",
		Geometry:   geometry,
		Properties: make(map[string]interface{}),
	}
}
429468
func (section *Section) ToJSON() ([]byte, error) {
	data := section.ToMap()
	return json.Marshal(data)
}
619890
func ToJSON(data []byte) ([]byte, error) {
	if hasJSONPrefix(data) {
		return data, nil
	}
	return yaml.YAMLToJSON(data)
}