gin/binding
waterWang b03993df02 fix(binding): respect time_format tag in JSON binding (ShouldBindJSON)
The time_format, time_utc, and time_location struct tags work correctly
for form/query binding (ShouldBindQuery, ShouldBindForm) but are
completely ignored when using ShouldBindJSON or ShouldBindBodyWithJSON.

encoding/json only understands RFC3339 for time.Time fields, so custom
time formats such as "2006-01-02 15:04:05" or "unix" produce a parse
error like:
  parsing time "2001-11-11 11:11:11" as "2006-01-02T15:04:05Z07:00":
  cannot parse " 11:11:11" as "T"

This fix replaces the single-pass JSON decode with a field-by-field
decode when the target struct has any time.Time field that carries a
time_format tag.  Fields with time_format are parsed by the existing
setTimeField helper (same one used by form binding), so all existing
tag features (time_format, time_utc, time_location, unix/unixmilli/
unixmicro/unixnano) work identically in JSON binding.

Fast path: when the struct has no time_format tags at all, the
original single-pass decoder.Decode path is used (zero overhead).

Fixes #2170
2026-08-10 09:51:07 +08:00
..
2025-04-12 00:00:59 +08:00
2022-05-30 15:16:10 +08:00