discovery/targetgroup/targetgroup.go
func (tg *Group) UnmarshalJSON(b []byte) error {
	g := struct {
		Targets []string       `json:"targets"`
		Labels  model.LabelSet `json:"labels"`
	}{}

	dec := json.NewDecoder(bytes.NewReader(b))
	dec.DisallowUnknownFields()
	if err := dec.Decode(&g); err != nil {
		return err
	}
	tg.Targets = make([]model.LabelSet, 0, len(g.Targets))
	for _, t := range g.Targets {
		tg.Targets = append(tg.Targets, model.LabelSet{
			model.AddressLabel: model.LabelValue(t),
		})
	}
	tg.Labels = g.Labels
	return nil
}
func (tg *Group) UnmarshalJSON(b []byte) error {
	g := struct {
		Targets []string       `json:"targets"`
		Labels  model.LabelSet `json:"labels"`
	}{}

	dec := json.NewDecoder(bytes.NewReader(b))
	dec.DisallowUnknownFields()
	if err := dec.Decode(&g); err != nil {
		return err
	}
	tg.Targets = make([]model.LabelSet, 0, len(g.Targets))
	for _, t := range g.Targets {
		tg.Targets = append(tg.Targets, model.LabelSet{
			model.AddressLabel: model.LabelValue(t),
		})
	}
	tg.Labels = g.Labels
	return nil
}
func ( tg * Group ) UnmarshalJSON ( b [ ] byte ) error { g := struct { Targets [ ] string `json:"targets"` Labels model . LabelSet `json:"labels"` } { } dec := json . NewDecoder ( bytes . NewReader ( b ) ) dec . DisallowUnknownFields ( ) if err := dec . Decode ( & g ) ; err != nil { return err } tg . Targets = make ( [ ] model . LabelSet , 0 , len ( g . Targets ) ) for _ , t := range g . Targets { tg . Targets = append ( tg . Targets , model . LabelSet { model . AddressLabel : model . LabelValue ( t ) , } ) } tg . Labels = g . Labels return nil }
// UnmarshalJSON implements the json.Unmarshaler interface.
UnmarshalJSON implements the json . Unmarshaler interface .