-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
| Previous ID | SR-7017 |
| Radar | None |
| Original Reporter | @lilyball |
| Type | Bug |
| Status | Closed |
| Resolution | Done |
Environment
Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2)
Target: x86_64-apple-macosx10.9
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Foundation |
| Labels | Bug |
| Assignee | None |
| Priority | Medium |
md5: da644e5cdf59c1c9ee3e87e02c010d6a
Issue Description:
JSONDecoder is perfectly happy to convert a boolean to a number. This is surprising.
Example:
import Foundation
struct Foo: Decodable {
let value: Int
}
let jsonData = "{ \"value\": true }".data(using: .utf8)!
let foo = try! JSONDecoder().decode(Foo.self, from: jsonData)
print(foo.value) // prints: 1