Skip to content
This repository has been archived by the owner on Oct 29, 2021. It is now read-only.

Codable with date encoding / decoding strategy #18

Closed
thang-nm opened this issue Jul 13, 2018 · 4 comments
Closed

Codable with date encoding / decoding strategy #18

thang-nm opened this issue Jul 13, 2018 · 4 comments

Comments

@thang-nm
Copy link

How can i add date encoding / decoding strategy to response.decode()?

@alexruperez
Copy link
Contributor

@Lang-le, can you tell us how do you finally fix this issue please? Thanks! 🙂

@thang-nm
Copy link
Author

@alexruperez, I decode manually from response?.object()

let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .formatted(myDateFormatter)
if let data: Data = try response?.object(),
    let json: MyClass = try? decoder.decode(MyClass.self, from: data) {
  // do something
}

@alexruperez
Copy link
Contributor

Ok @Lang-le, I'll try to integrate dateDecodingStrategy in the decode() method, reopening the issue, thanks for the feedback! 🙌

@alexruperez
Copy link
Contributor

Working @Lang-le, thanks again!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants