I\'m getting this exception when I try to JSON encode NSDate object.I believe NSDate is not compatible for JSON encoding. but I must encode the date.Any solutions?
I am doing something like this in my body params encoder
// handle dates
var _params = [String: Any]()
params.forEach { (key, value) in
if let date = value as? Date {
_params[key] = DateFormatter.iso8601Full.string(from: date)
} else {
_params[key] = value
}
}
return try? JSONSerialization.data(withJSONObject: _params)