Last active
November 16, 2020 10:22
-
-
Save cuongld2/a9ab76b46f374c41e119e629e70c9d01 to your computer and use it in GitHub Desktop.
Unmarshal dynamic key in JSON
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
func (s ResultObject) UnmarshalJSON(data []byte) map[string]interface{} { | |
var z map[string]interface{} | |
if err := json.Unmarshal(data, &z); err != nil { | |
fmt.Println(string(data[:])) | |
panic(err) | |
} | |
return z | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment