package utils

import (
	"reflect"
)

func Pb2Map(rp interface{}) map[string]interface{} {
	m := make(map[string]interface{})
	vals := reflect.ValueOf(rp).Elem()
	for i := 0; i < vals.NumField(); i++ {
		valueField := vals.Field(i)
		typeField := vals.Type().Field(i)

		if valueField.CanInterface() {
			f := valueField.Interface()
			// val := reflect.ValueOf(f)
			m[typeField.Tag.Get("json")] = f //可以根据需要取具体的tag，做相应的处理即可
		}
	}
	return m
}
