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

Add support for decoding Date type #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Sources/AnyCodable/AnyDecodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ extension _AnyDecodable {
self.init(double)
} else if let string = try? container.decode(String.self) {
self.init(string)
} else if let date = try? container.decode(Date.self) {
self.init(date)
} else if let array = try? container.decode([AnyDecodable].self) {
self.init(array.map { $0.value })
} else if let dictionary = try? container.decode([String: AnyDecodable].self) {
Expand Down Expand Up @@ -112,6 +114,8 @@ extension AnyDecodable: Equatable {
return lhs == rhs
case let (lhs as String, rhs as String):
return lhs == rhs
case let (lhs as Date, rhs as Date):
return lhs == rhs
case let (lhs as [String: AnyDecodable], rhs as [String: AnyDecodable]):
return lhs == rhs
case let (lhs as [AnyDecodable], rhs as [AnyDecodable]):
Expand Down Expand Up @@ -177,6 +181,8 @@ extension AnyDecodable: Hashable {
hasher.combine(value)
case let value as String:
hasher.combine(value)
case let value as Date:
hasher.combine(value)
case let value as [String: AnyDecodable]:
hasher.combine(value)
case let value as [AnyDecodable]:
Expand Down