Skip to content

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

Merged
dfinkel merged 3 commits intomasterfrom
parsingduration_json_cue
May 20, 2024
Merged

json/cue: substitute time.Duration with type using time.ParseDuration#92
dfinkel merged 3 commits intomasterfrom
parsingduration_json_cue

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).

dfinkel added 3 commits May 17, 2024 15:51
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`.
@dfinkel dfinkel force-pushed the parsingduration_json_cue branch from 836bb49 to fe58cd1 Compare May 19, 2024 15:21
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
@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