Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
json deserialisation broken first try
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
You can’t perform that action at this time.