func MapToStruct(s interface{}, m map[string]dbus.Variant) error {
	for k, v := range m {
		err := mapStructField(s, k, v)
		if err != nil {
			return err
		}
	}
	return nil
}
MapToStruct converts a map[string]interface{} to a struct
package util
import (
	"fmt"
	"reflect"
	"github.com/godbus/dbus/v5"
	log "github.com/sirupsen/logrus"
)
func AssignMapVariantToInterface(mapVal reflect.Value, mapVariant reflect.Value) (bool, error) {
	if mapVal.Type().Kind() != reflect.Map {
		return false, nil
	}
	if mapVariant.Type().Kind() != reflect.Map {
		return false, nil
	}
	mapValT := mapVal.Type()
	mapValKey := mapValT.Key()
	mapValValue := mapValT.Elem()
	mapVariantT := mapVariant.Type()
	mapVariantKey := mapVariantT.Key()
	mapVariantValue := mapVariantT.Elem()
	if mapValKey.Kind() != mapVariantKey.Kind() {
		return false, fmt.Errorf(
			"Cannot set values on different types: map[%s] with map[%s]",
			mapValKey.Kind().String(),
			mapVariantKey.Kind().String(),
		)
	}
	if mapValValue.Kind() != reflect.Interface {
		log.Debugf("val is not interface")
		return false, nil
	}
	if mapVariantValue.Kind() != reflect.TypeOf(dbus.Variant{}).Kind() {
		log.Debugf("mapVariant value is not variant")
		return false, nil
	}
	mapValInstanceType := reflect.MapOf(mapValKey, mapValValue)
	mapValInstance := reflect.MakeMapWithSize(mapValInstanceType, mapVariant.Len())
	for _, key := range mapVariant.MapKeys() {
		variantInnerValue := mapVariant.MapIndex(key).MethodByName("Value").Call([]reflect.Value{})
		mapValInstance.SetMapIndex(key, variantInnerValue[0])
	}
	mapVal.Set(mapValInstance)
	return true, nil
}
func mapStructField(obj interface{}, name string, value dbus.Variant) error {
	structValue := reflect.ValueOf(obj).Elem()
	structFieldValue := structValue.FieldByName(name)
	if !structFieldValue.IsValid() {
		return fmt.Errorf("Field not found: %s", name)
	}
	if !structFieldValue.CanSet() {
		return fmt.Errorf("Cannot set value for: %s", name)
	}
	structFieldType := structFieldValue.Type()
	val := reflect.ValueOf(value.Value())
	if structFieldType == val.Type() {
		structFieldValue.Set(val)
		return nil
	}
	if val.Type().Kind() == reflect.Map {
		structVal := structFieldType.Elem()
		structKey := structFieldType.Key()
		mapKey := val.Type().Key()
		if mapKey.Kind() != structKey.Kind() {
			return fmt.Errorf("Field %s: map key mismatchig values object=%s props=%s", name, structKey.Kind(), mapKey.Kind())
		}
		if structVal.Kind() == reflect.Interface {
			val1MapType := reflect.MapOf(structKey, structVal)
			val1Map := reflect.MakeMapWithSize(val1MapType, val.Len())
			for _, key := range val.MapKeys() {
				val1Map.SetMapIndex(key, val.MapIndex(key))
			}
			structFieldValue.Set(val1Map)
			return nil
		}
	}
	if val.Type().Kind() == reflect.Array {
		log.Warn("@TODO type array to interface{} is not implemented")
	}
	return fmt.Errorf("Mismatching types for field=%s object=%s props=%s", name, structFieldType, val.Type())
}