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

Encode & decode with not default dateEncodingStrategy #17

Closed
nixzhu opened this issue Oct 24, 2017 · 3 comments
Closed

Encode & decode with not default dateEncodingStrategy #17

nixzhu opened this issue Oct 24, 2017 · 3 comments

Comments

@nixzhu
Copy link
Contributor

nixzhu commented Oct 24, 2017

I think we need to pass encoder & decoder if necessary.
A pull request is here #16

@saoudrizwan
Copy link
Owner

Hey @nixzhu thanks for your PR!

I don't think adding this extra step is necessary for the sake of simplicity when using Disk for most use cases.

In your case, where you want to change some of the JSONEncoder's properties, like it's date coding strategy, I suggest you convert your Codable struct to Data first using your own JSONEncoder and then using Disk to save that data, Disk.save(data, to: .documents, as: "messages.json")

@nixzhu
Copy link
Contributor Author

nixzhu commented Oct 24, 2017

But there is append for Codable, in that case, data is not enough.

@jyounus
Copy link

jyounus commented Nov 6, 2017

nixzhu's PR allows users to pass a custom decoder/encoder or use the default one. So merging it shouldn't cause any issue to existing code. It would be great if it could be merged, it would keep things nice and simple, rather than converting into a Data object back and forth.

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

No branches or pull requests

3 participants