The MyAnimeList API inconsistently returns statistics status fields (watching, completed, on_hold, dropped, plan_to_watch) as quoted strings for non-zero values (e.g. "8217") but as bare numbers for zero values (e.g. 0). This caused JSON unmarshal errors for anime with zero counts in any status field. Introduce a FlexString custom type that implements json.Unmarshaler to accept both JSON strings and JSON numbers, always storing the result as a string. The type definition lives in MALTypes.go and the unmarshal logic in MALFunctions.go to keep static types and behavior separate.
7.8 KiB
7.8 KiB