元帅/非元帅体现

I created map[string]interface{} and i want to pass multiple types through the map between 2 reset services.

every time i marshal i get empty map in the field that should contain reflect.Type.

ServiceType:map[]

is it even possible?

code for testing: (the KeyValuePair will represent a single value of the map) and the MessageService can be replaced with any type of course

data := GenericHandlers.KeyValuePair{Key:"ServiceType",Value:reflect.TypeOf(MessageService.MessageService{})}
Json , _ := json.Marshal(data)
resKvp := GenericHandlers.KeyValuePair{}
err := json.Unmarshal(Json,&resKvp)
if(err != nil){
     log.Println(err.Error())
}
fmt.Println(resKvp)


type KeyValuePair struct{
        Key string
        Value interface{}
}

Short answer: No, it's not possible.

Slightly longer answer: Since relfect.Type, as returned by TypeOf, is an interface type implemented by the unexported type rtype, none of whose fields are exported and whose method set does not contain the MarshalJSON/UnmarshalJSON methods, you cannot marshal or unmarshal a reflect.Type value as is.