Open minacle opened 4 years ago
I've checked some structures presented by Foundation framework, and tested them.
There are JSON coders and _PropertyList coders in Foundation framework, so I tested them on JSONEncoder and PropertyListEncoder using this simple script.
And results are below:
AnyEncodable<Array
>
- [JSON] PASS.
- [PLIST] PASS.
Array
- [JSON] PASS.
- [PLIST] PASS.
AnyEncodable
- [JSON] ERROR.
- [PLIST] ERROR.
Calendar
- [JSON] PASS.
- [PLIST] PASS.
AnyEncodable
- [JSON] ERROR.
- [PLIST] ERROR.
CharacterSet
- [JSON] PASS.
- [PLIST] PASS.
AnyEncodable
- [JSON] ERROR.
- [PLIST] ERROR.
Data
- [JSON] PASS.
- [PLIST] PASS.
AnyEncodable
- [JSON] PASS.
- [PLIST] ERROR.
Date
- [JSON] PASS.
- [PLIST] ERROR.
AnyEncodable
- [JSON] ERROR.
- [PLIST] ERROR.
DateInterval
- [JSON] PASS.
- [PLIST] PASS.
AnyEncodable
- [JSON] PASS.
- [PLIST] ERROR.
NSDecimal
- [JSON] PASS.
- [PLIST] PASS.
AnyEncodable<Dictionary<String, Int>>
- [JSON] PASS.
- [PLIST] PASS.
Dictionary<String, Int>
- [JSON] PASS.
- [PLIST] PASS.
AnyEncodable
- [JSON] ERROR.
- [PLIST] ERROR.
IndexPath
- [JSON] PASS.
- [PLIST] PASS.
AnyEncodable
- [JSON] ERROR.
- [PLIST] ERROR.
IndexSet
- [JSON] PASS.
- [PLIST] PASS.
AnyEncodable
- [JSON] ERROR.
- [PLIST] ERROR.
Locale
- [JSON] PASS.
- [PLIST] PASS.
AnyEncodable<Set
>
- [JSON] ERROR.
- [PLIST] ERROR.
Set
- [JSON] PASS.
- [PLIST] PASS.
AnyEncodable
- [JSON] PASS.
- [PLIST] ERROR.
String
- [JSON] PASS.
- [PLIST] ERROR.
AnyEncodable
- [JSON] ERROR.
- [PLIST] ERROR.
TimeZone
- [JSON] PASS.
- [PLIST] PASS.
AnyEncodable
- [JSON] PASS.
- [PLIST] PASS.
URL
- [JSON] PASS.
- [PLIST] PASS.
AnyEncodable
- [JSON] ERROR.
- [PLIST] ERROR.
UUID
- [JSON] PASS.
- [PLIST] ERROR.
According to results, AnyCodable doesn't cover some major types, and it doesn't support PropertyList coders completely.
Thanks for you types.
I re-implemented it to support "exact type", which is that types like UInt
won't be implicitly coerced.
Already passed the test using the types you mentioned above, except Calendar
and Local
. Somehow, even after encoding and decoding using JSONEncoder
and JSONDecoder
, the result is still not equatable. Any there will be a crash if Calendar
and Locale
are both supported at the same time. Still needs further researches.
You can check it out here.
There are huge changes, so I didn't prepare to pr.😶
I've checked some structures presented by Foundation framework, and tested them.
There are JSON coders and _PropertyList coders in Foundation framework, so I tested them on JSONEncoder and PropertyListEncoder using this simple script.
And results are below:
AnyEncodable\<Array\>
Array
AnyEncodable\
Calendar
AnyEncodable\
CharacterSet
AnyEncodable\
Data
AnyEncodable\
Date
AnyEncodable\
DateInterval
AnyEncodable\
NSDecimal
AnyEncodable\<Dictionary\<String, Int>>
Dictionary\<String, Int>
AnyEncodable\
IndexPath
AnyEncodable\
IndexSet
AnyEncodable\
Locale
AnyEncodable\<Set\>
Set\
AnyEncodable\
String
AnyEncodable\
TimeZone
AnyEncodable\
URL
AnyEncodable\
UUID
According to results, AnyCodable doesn't cover some major types, and it doesn't support PropertyList coders completely.