TL;DR When working with an API that returned json with inconsistent types, json.Unmarshal would fail because it was mapped to a matching Go type via tags in the struct. The solution was to create a new type to support any permutation of data the API might return, and have that type implement Unmarshaler or UnmarshalerFrom interfaces to add the logic to decode this correctly. Problem When working writing an API client, I was relying on Go's standard library encoding/json in order to decode JSO...
No comments yet. Log in to discuss on the Fediverse