Created
May 6, 2020 16:20
-
-
Save yukin01/648a91b84c3223233862a833c6cc71ec to your computer and use it in GitHub Desktop.
Convert json struct to map in Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "encoding/json" | |
func structToMap(s interface{}) map[string]interface{} { | |
m := make(map[string]interface{}) | |
b, _ := json.Marshal(s) | |
json.Unmarshal(b, &m) | |
return m | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment