package main
import (
"encoding/json"
"fmt"
)
type User struct {
Name string `json:"name"`
}
func FillStruct(m map[string]interface{}, s interface{}) {
j, _ := json.Marshal(m)
json.Unmarshal(j, s)
}
func main() {
// Initial map
user_map := map[string]interface{}{
"name": "Fulanito",
}
fmt.Println(user_map)
// Empty User
user_object := &User{}
// Fill Object
FillStruct(user_map, user_object)
fmt.Println(user_object.Name)
}