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 marshal/unmarshal #4

Open
Semior001 opened this issue Aug 31, 2023 · 4 comments · May be fixed by #5
Open

json marshal/unmarshal #4

Semior001 opened this issue Aug 31, 2023 · 4 comments · May be fixed by #5
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Semior001
Copy link
Member

Right now these types don't support marshal/unmarshal from/to json, but implementing this might be pretty handy in the future.

@Semior001 Semior001 added enhancement New feature or request good first issue Good for newcomers labels Aug 31, 2023
@krishnaduttPanchagnula
Copy link

do you want just to change types like below

type Range struct {
	St  time.Time       `json:"st"`
	Dur time.Duration   `json:"dur"`
}

or do you want to also add methods to marshall/unmarshall them ?

@Semior001
Copy link
Member Author

I think it would be nice if we marshal it as {"start": "2006-01-02T15:04:05Z07:00", "end": "2006-01-02T15:04:05Z07:00"}. At least among my cases it is rarely needed to get the duration in json, but it is often needed to use the end time.

This would involve implementing marshal/unmarshal methods for the type.

@krishnaduttPanchagnula
Copy link

The type doesnt have end as attribute right ? are we going to add another struct using the range struct just for this usage ?

@Semior001
Copy link
Member Author

The type doesnt have end as attribute right ?

Yes, type doesn't have the end time among its fields. That was done purposefully, so we won't have to keep an eye on the consistency between the start and end time, so we don't want the end field to be added to the type.

are we going to add another struct using the range struct just for this usage ?

That would be the option. Another struct that would be used just to marshal/unmarshal the period itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants