func (d decoder) unmarshalMapKey(tok json.Token, fd pref.FieldDescriptor) (pref.MapKey, error) {
	const b32 = 32
	const b64 = 64
	const base10 = 10

	name := tok.Name()
	kind := fd.Kind()
	switch kind {
	case pref.StringKind:
		return pref.ValueOfString(name).MapKey(), nil

	case pref.BoolKind:
		switch name {
		case "true":
			return pref.ValueOfBool(true).MapKey(), nil
		case "false":
			return pref.ValueOfBool(false).MapKey(), nil
		}

	case pref.Int32Kind, pref.Sint32Kind, pref.Sfixed32Kind:
		if n, err := strconv.ParseInt(name, base10, b32); err == nil {
			return pref.ValueOfInt32(int32(n)).MapKey(), nil
		}

	case pref.Int64Kind, pref.Sint64Kind, pref.Sfixed64Kind:
		if n, err := strconv.ParseInt(name, base10, b64); err == nil {
			return pref.ValueOfInt64(int64(n)).MapKey(), nil
		}

	case pref.Uint32Kind, pref.Fixed32Kind:
		if n, err := strconv.ParseUint(name, base10, b32); err == nil {
			return pref.ValueOfUint32(uint32(n)).MapKey(), nil
		}

	case pref.Uint64Kind, pref.Fixed64Kind:
		if n, err := strconv.ParseUint(name, base10, b64); err == nil {
			return pref.ValueOfUint64(uint64(n)).MapKey(), nil
		}

	default:
		panic(fmt.Sprintf("invalid kind for map key: %v", kind))
	}

	return pref.MapKey{}, d.newError(tok.Pos(), "invalid value for %v key: %s", kind, tok.RawString())
}
// unmarshalMapKey converts given token of Name kind into a protoreflect.MapKey.
// A map key type is any integral or string type.
unmarshalMapKey converts given token of Name kind into a protoreflect.MapKey.
A map key type is any integral or string type.
// unmarshalMapKey converts given token of Name kind into a protoreflect . MapKey . // A map key type is any integral or string type .
func (d decoder) unmarshalMapKey(tok json.Token, fd pref.FieldDescriptor) (pref.MapKey, error) {
	const b32 = 32
	const b64 = 64
	const base10 = 10
	name := tok.Name()
	kind := fd.Kind()
	switch kind {
	case pref.StringKind:
		return pref.ValueOfString(name).MapKey(), nil
	case pref.BoolKind:
		switch name {
		case "true":
			return pref.ValueOfBool(true).MapKey(), nil
		case "false":
			return pref.ValueOfBool(false).MapKey(), nil
		}
	case pref.Int32Kind, pref.Sint32Kind, pref.Sfixed32Kind:
		if n, err := strconv.ParseInt(name, base10, b32); err == nil {
			return pref.ValueOfInt32(int32(n)).MapKey(), nil
		}
	case pref.Int64Kind, pref.Sint64Kind, pref.Sfixed64Kind:
		if n, err := strconv.ParseInt(name, base10, b64); err == nil {
			return pref.ValueOfInt64(int64(n)).MapKey(), nil
		}
	case pref.Uint32Kind, pref.Fixed32Kind:
		if n, err := strconv.ParseUint(name, base10, b32); err == nil {
			return pref.ValueOfUint32(uint32(n)).MapKey(), nil
		}
	case pref.Uint64Kind, pref.Fixed64Kind:
		if n, err := strconv.ParseUint(name, base10, b64); err == nil {
			return pref.ValueOfUint64(uint64(n)).MapKey(), nil
		}
	default:
		panic(fmt.Sprintf("invalid kind for map key: %v", kind))
	}
	return pref.MapKey{}, d.newError(tok.Pos(), "invalid value for %v key: %s", kind, tok.RawString())
}
func ( d decoder ) unmarshalMapKey ( tok json . Token , fd pref . FieldDescriptor ) ( pref . MapKey , error ) { const b32 = 32 const b64 = 64 const base10 = 10 name := tok . Name ( ) kind := fd . Kind ( ) switch kind { case pref . StringKind : return pref . ValueOfString ( name ) . MapKey ( ) , nil case pref . BoolKind : switch name { case " " : return pref . ValueOfBool ( true ) . MapKey ( ) , nil case " " : return pref . ValueOfBool ( false ) . MapKey ( ) , nil } case pref . Int32Kind , pref . Sint32Kind , pref . Sfixed32Kind : if n , err := strconv . ParseInt ( name , base10 , b32 ) ; err == nil { return pref . ValueOfInt32 ( int32 ( n ) ) . MapKey ( ) , nil } case pref . Int64Kind , pref . Sint64Kind , pref . Sfixed64Kind : if n , err := strconv . ParseInt ( name , base10 , b64 ) ; err == nil { return pref . ValueOfInt64 ( int64 ( n ) ) . MapKey ( ) , nil } case pref . Uint32Kind , pref . Fixed32Kind : if n , err := strconv . ParseUint ( name , base10 , b32 ) ; err == nil { return pref . ValueOfUint32 ( uint32 ( n ) ) . MapKey ( ) , nil } case pref . Uint64Kind , pref . Fixed64Kind : if n , err := strconv . ParseUint ( name , base10 , b64 ) ; err == nil { return pref . ValueOfUint64 ( uint64 ( n ) ) . MapKey ( ) , nil } default : panic ( fmt . Sprintf ( " " , kind ) ) } return pref . MapKey { } , d . newError ( tok . Pos ( ) , " " , kind , tok . RawString ( ) ) }
unmarshalMapKey converts given token of Name kind into a protoreflect.MapKey.
unmarshalMapKey converts given token of Name kind into a protoreflect . MapKey .