json/cue: substitute time.Duration with type using time.ParseDuration#92
Merged
json/cue: substitute time.Duration with type using time.ParseDuration#92
Conversation
Currently only one type: ParsingDuration, which handles both integer-nanoseconds and time.ParseDuration-compatible strings. This makes it compatible with any existing JSON config files, while expanding support for human readable strings.
Also, move the close-brace for the empty Decoder struct onto the same line as the open-brace.
Integrate the new jsontypes.ParsingDuration type into the cue and json decoders via the `SingleTypeSubstitutionMangler`.
836bb49 to
fe58cd1
Compare
sergiosalvatore
approved these changes
May 20, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a
jsontypespackage with aParsingDurationtype that implementsjson.Unmarshaler, making it possible to use both human-friendly strings (3s) and integer nanoseconds (for compatibility).Leverage the new
SingleTypeSubstitutionManglerto make this substitution in the cue and json decoders (during decoding).