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

json/cue: substitute time.Duration with type using time.ParseDuration #92

Merged
merged 3 commits into from
May 20, 2024

Conversation

dfinkel
Copy link
Contributor

@dfinkel dfinkel commented May 17, 2024

Add a jsontypes package with a ParsingDuration type that implements json.Unmarshaler, making it possible to use both human-friendly strings (3s) and integer nanoseconds (for compatibility).

Leverage the new SingleTypeSubstitutionMangler to make this substitution in the cue and json decoders (during decoding).

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`.
Base automatically changed from single_type_substitution_mangler to master May 20, 2024 17:47
@dfinkel dfinkel merged commit 875c7b5 into master May 20, 2024
8 checks passed
@dfinkel dfinkel deleted the parsingduration_json_cue branch May 20, 2024 17:47
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