// MarshalJSON converts the feature object into the proper JSON.
// It will handle the encoding of all the child geometries.
// Alternately one can call json.Marshal(f) directly for the same result.
323309
func (f Feature) MarshalJSON() ([]byte, error) {
	jf := &jsonFeature{
		ID:         f.ID,
		Type:       "Feature",
		Properties: f.Properties,
		BBox:       f.BBox,
		Geometry:   NewGeometry(f.Geometry),
	}

	if len(jf.Properties) == 0 {
		jf.Properties = nil
	}

	return json.Marshal(jf)
}
957573
func (t T) MarshalJSON() ([]byte, error) {
	params := map[string]interface{}{
		"from": t.From,
	}
	if t.To != "" {
		params["to"] = t.To
	}
	if t.Gas > 0 {
		params["gas"] = IntToHex(t.Gas)
	}
	if t.GasPrice != nil {
		params["gasPrice"] = BigToHex(*t.GasPrice)
	}
	if t.Value != nil {
		params["value"] = BigToHex(*t.Value)
	}
	if t.Data != "" {
		params["data"] = t.Data
	}
	if t.Nonce > 0 {
		params["nonce"] = IntToHex(t.Nonce)
	}

	return json.Marshal(params)
}
251645
func (args Args) MarshalJSON() ([]byte, error) {
	if len(args.fields) == 0 {
		return []byte{}, nil
	}
	return json.Marshal(args.fields)
}
1007075
func (v CBGravatar) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjsonB0500db0EncodeGithubComFrancoispqtGojayBenchmarks3(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}
928276
func (mls MultiLineString) MarshalJSON() ([]byte, error) {
	return json.Marshal(Geometry{Coordinates: orb.MultiLineString(mls)})
}
1189892
func (ls LineString) MarshalJSON() ([]byte, error) {
	return json.Marshal(Geometry{Coordinates: orb.LineString(ls)})
}
1344539
func (d *Document) MarshalJSON() ([]byte, error) {
	// we use the MarshalDoc type to avoid recursively calling this function below
	// when we marshal
	type MarshalDoc Document
	doc := MarshalDoc(*d)

	switch d.Mode {
	case ObjectMode:
		var data *Object
		if len(d.Data) > 0 {
			data = d.Data[0]
		}

		// subtype that overrides regular data List with a single Object for
		// fetch style request/responses
		type MarshalObject struct {
			MarshalDoc
			Data *Object `json:"data"`
		}

		return json.Marshal(MarshalObject{
			MarshalDoc: doc,
			Data:       data,
		})

	case ErrorMode:
		// subtype that omits data as expected for error responses. We cannot simply
		// use json:"-" for the data attribute otherwise it will not override the
		// default struct tag of it the composed MarshalDoc struct.
		type MarshalError struct {
			MarshalDoc
			Data *Object `json:"data,omitempty"`
		}

		return json.Marshal(MarshalError{
			MarshalDoc: doc,
		})

	case ListMode:
		return json.Marshal(doc)
	default:
		return nil, ISE(fmt.Sprintf("Unexpected DocumentMode value when marshaling: %d", d.Mode))
	}
}
268695
func (e Unknown) MarshalJSON() ([]byte, error) {
	// If ContentType is unset, we assume this is JSON.
	if e.ContentType != "" && e.ContentType != ContentTypeJSON {
		return nil, errors.New("runtime.Unknown: MarshalJSON on non-json data")
	}
	if e.Raw == nil {
		return []byte("null"), nil
	}
	return e.Raw, nil
}
306401
func (that *JSONNode) MarshalJSON() ([]byte, error) {
	var ret []byte
	var err error
	switch that.t {
	case TypeMap:
		ret, err = json.Marshal(that.m)
	case TypeArray:
		ret, err = json.Marshal(that.a)
	case TypeValue:
		ret, err = json.Marshal(that.v)
	default:
		ret, err = json.Marshal(nil)
	}
	if err != nil {
		return nil, err
	}
	return ret, err
}
470679
func (s *StringRule) MarshalJSON() ([]byte, error) {
	return json.Marshal(&struct {
		Key      string             `json:"key"`
		Required bool               `json:"required"`
		Default  ctypes.ConfigValue `json:"default"`
		Type     string             `json:"type"`
	}{
		Key:      s.key,
		Required: s.required,
		Default:  s.Default(),
		Type:     StringType,
	})
}
548109
func (b Buffer) MarshalJSON() ([]byte, error) {
	v, err := b.Base64Encode()
	if err != nil {
		return nil, errors.Wrap(err, "failed to encode to base64")
	}
	return json.Marshal(string(v))
}
281339
func (results Results) MarshalJSON() ([]byte, error) {
	for _, result := range results {
		if result.ResultID() == "" {
			result.SetResultID(fmt.Sprintf("%d", &result))
		}

		if err := inferIQR(result); err != nil {
			return nil, err
		}
	}

	return json.Marshal([]Result(results))
}
1212123
func (fc FeatureCollection) MarshalJSON() ([]byte, error) {
	type tempFC FeatureCollection

	c := tempFC{
		Type:     featureCollection,
		BBox:     fc.BBox,
		Features: fc.Features,
	}

	if c.Features == nil {
		c.Features = []*Feature{}
	}
	return json.Marshal(c)
}
508831
func (e encodable) MarshalJSON() ([]byte, error) {
	return Encode(e.E, e.obj)
}
898799
func (s *Surface) MarshalJSON() ([]byte, error) {
	return json.Marshal(map[string]interface{}{
		"bound":  s.bound,
		"values": s.Grid,
	})
}
973891
func (re encodable) MarshalJSON() ([]byte, error) {
	return Encode(re.e, re.obj)
}
418797
func (p *Point) MarshalJSON() ([]byte, error) {
	res := fmt.Sprintf(`{"lat":%v, "lng":%v}`, p.lat, p.lng)
	return []byte(res), nil
}