Treating strings as numbers in Golang

Today I encountered an API which sometimes sends back numbers as strings. Example response: { "age": "30" } That’s annoying, because I wanted my struct in Go to be like this: type Person struct { Age int `json:"age"` } I learned that json struct tags have a string option meant for dealing with exactly this sort of problem: The “string” option signals that a field is stored as JSON inside a JSON-encoded string....

2025-08-28