Skip to content

Instantly share code, notes, and snippets.

@cuongld2
Last active November 16, 2020 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cuongld2/a9ab76b46f374c41e119e629e70c9d01 to your computer and use it in GitHub Desktop.
Save cuongld2/a9ab76b46f374c41e119e629e70c9d01 to your computer and use it in GitHub Desktop.
Unmarshal dynamic key in JSON
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