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

Fix wrong ObjC type mapping #65

Closed bddq closed 2 years ago

bddq commented 2 years ago

Issue occurred when I used AnyCodable between ObjC and Swift code with NSNumber.

Following ObjC code: @(700000004)

Encoded value in Swift: 9988

Because encode(nsnumber: container:) applied container.encode(nsnumber.int16Value) instead of container.encode(nsnumber.int32Value).

There was an error in the switch. I checked on Apple documentation and updated accordingly.

pyrou commented 2 years ago

Bug introduced in #57

antoineOpuscope commented 2 years ago

Why from this PR bool are 1 or 0 in json instead of true and false. Looks like it is intended because you have modified the tests about that.

bddq commented 2 years ago

I didn't find any clue about why all tests are ok on iOS but not on Linux. Maybe you can help me to understand.

You can check tests results on the PR.

jordanekay commented 2 years ago

This PR broke the tests in my package that relies on this one.