Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle string option for time types similar to other types #118

Merged
merged 1 commit into from
Jan 3, 2025

Conversation

dsnet
Copy link
Collaborator

@dsnet dsnet commented Jan 3, 2025

WARNING: This commit includes breaking changes.

Previously, if StringifyNumbers was specified,
we would permit unmarshaling of a JSON number into a Go number. However, this is not how the v1 equivalent functionality operated. In v1, once the string tag option was specified, it would only unmarshal a JSON string containing a JSON number, but would reject a JSON number.

In #60, we made v2 more consistent with v1 for regular numeric types, but forgot to do so for time.Duration as well.

Also, in #91, we no longer specify StringifyNumbers for map keys and expect a type to check the JSON state machine to handle object names specially. Do the same for time.Duration and time.Time.

WARNING: This commit includes breaking changes.

Previously, if StringifyNumbers was specified,
we would permit unmarshaling of a JSON number into a Go number.
However, this is not how the v1 equivalent functionality operated.
In v1, once the `string` tag option was specified,
it would only unmarshal a JSON string containing a JSON number,
but would reject a JSON number.

In #60, we made v2 more consistent with v1 for regular numeric types,
but forgot to do so for time.Duration as well.

Also, in #91, we no longer specify StringifyNumbers for map keys
and expect a type to check the JSON state machine to handle
object names specially. Do the same for time.Duration and time.Time.
@dsnet dsnet requested review from mvdan and johanbrandhorst January 3, 2025 10:43
@dsnet dsnet merged commit ec56a69 into master Jan 3, 2025
8 checks passed
@dsnet dsnet deleted the time-string branch January 3, 2025 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants