Created
July 31, 2018 18:57
-
-
Save kevholditch/57d2d58890d450f562cd73c115c03dae to your computer and use it in GitHub Desktop.
json deserialisation broken first try
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 (a *Api) UnmarshalJSON(data []byte) error { | |
fixedJson := strings.Replace(string(data), `"hosts":{}`, `"hosts":[]`, -1) | |
fixedJson = strings.Replace(fixedJson, `"uris":{}`, `"uris":[]`, -1) | |
fixedJson = strings.Replace(fixedJson, `"methods":{}`, `"methods":[]`, -1) | |
return json.Unmarshal([]byte(fixedJson), &a) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment