I like explicit response helpers because they prevent subtle inconsistencies: missing Content-Type, forgetting Cache-Control, or writing headers after the body has started. A WriteJSON function centralizes the “happy path” and makes error handling consistent too. The key is to set headers before WriteHeader, and to handle json.Marshal errors (which can happen if you accidentally include channels, funcs, or cyclic data). In production, I also add an option to pretty-print for non-prod environments, and I make sure errors are not leaking internal messages. This helper is intentionally small: it doesn’t try to be a framework, it just standardizes the output contract. When combined with a typed error-to-HTTP mapping, you get predictable responses that are easy to test with httptest and easy to consume from clients.