Skip to content

Instantly share code, notes, and snippets.

@sheki
Created November 20, 2013 19:34
Show Gist options
  • Select an option

  • Save sheki/7569546 to your computer and use it in GitHub Desktop.

Select an option

Save sheki/7569546 to your computer and use it in GitHub Desktop.
type files map[string]map[string]string
func (f *files) UnmarshalJSON(data []byte) error {
fmt.Println("GOT : ", string(data))
*f = make(map[string]map[string]string)
if err := json.Unmarshal(data, f); err == nil {
return nil
}
m := make(map[string]string)
if err := json.Unmarshal(data, &m); err != nil {
return errors.New("Cannot parse to files struct " + err.Error())
}
(*f)["cloud"] = m
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment