func (bc *BalancerConfig) UnmarshalJSON(b []byte) error {
	var ir intermediateBalancerConfig
	err := json.Unmarshal(b, &ir)
	if err != nil {
		return err
	}
	for i, lbcfg := range ir {
		if len(lbcfg) != 1 {
			return fmt.Errorf("invalid loadBalancingConfig: entry %v does not contain exactly 1 policy/config pair: %q", i, lbcfg)
		}
		var (
			name    string
			jsonCfg json.RawMessage
		)
		for name, jsonCfg = range lbcfg {
		}
		builder := balancer.Get(name)
		if builder == nil {
			continue
		}
		bc.Name = name
		parser, ok := builder.(balancer.ConfigParser)
		if !ok {
			if string(jsonCfg) != "{}" {
				logger.Warningf("non-empty balancer configuration %q, but balancer does not implement ParseConfig", string(jsonCfg))
			}
			return nil
		}
		cfg, err := parser.ParseConfig(jsonCfg)
		if err != nil {
			return fmt.Errorf("error parsing loadBalancingConfig for policy %q: %v", name, err)
		}
		bc.Config = cfg
		return nil
	}
	return fmt.Errorf("invalid loadBalancingConfig: no supported policies found")
}
UnmarshalJSON implements the json.Unmarshaler interface.

ServiceConfig contains a list of loadBalancingConfigs, each with a name and
config. This method iterates through that list in order, and stops at the
first policy that is supported.
- If the config for the first supported policy is invalid, the whole service
config is invalid.
- If the list doesn't contain any supported policy, the whole service config
is invalid.
package serviceconfig
import (
	"encoding/json"
	"fmt"
	"time"
	"google.golang.org/grpc/balancer"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/grpclog"
	externalserviceconfig "google.golang.org/grpc/serviceconfig"
)
var logger = grpclog.Component("core")
type BalancerConfig struct {
	Name   string
	Config externalserviceconfig.LoadBalancingConfig
}
type intermediateBalancerConfig []map[string]json.RawMessage