when i try to parse my json with decodable birthday comes nil. What date format should I use any advice or code sample please. my date format include timezone.
My problem is birthdate comes nil. How to parse birthdate with decodable ?
My json :
{
"id": 1,
"name": "fatih",
"birddate": "2018-09-19T11:36:00.4033163+03:00",
"total": 0.9,
"isTest": false
}
here is my struct :
struct TestDTO : Decodable {
var id:Int?
var name : String?
var birtdate : Date?
var total : Double?
var isTest : Bool?
}
RestClientServiceTest().CallRestService(matching: cmd, completion: { (data) in
do{
let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .formatted(dateFormatter)
let stories = try decoder.decode(TestDTO.self, from: data!)
print(data)
}catch let error{
print("Json Parse Error : \(error)")
}
})