Flight-School / AnyCodable

Type-erased wrappers for Encodable, Decodable, and Codable values
https://flight.school/books/codable
MIT License
1.28k stars 132 forks source link

NSNUmber is converting to Bool #77

Open filipepereira-ag opened 1 year ago

filipepereira-ag commented 1 year ago

When dictionary contains an NSNumber as 0 or 1, encodable method is mapping to true or false because 0 or 1 is also a boolean for swift.

I think this bug was introduced in #69 because NSNumber condition was removed from the first switch statement.

Example:

var dictionary = [
     "int": NSNumber(0)
] 

AnyEncodable is returning ["int": false]. This problem only happens from version 0.6.5.