[Xcode 9, Swift 4]
I test following code:
Why the output is -1, not 1?
class A: Codable {
}
class A_a: A {
var a: Int = -1
}
let json = """
{
"a": 1
}
"""
let jsonData = json.data(using: .utf8)!
let obj = try? JSONDecoder().decode(A_a.self, from: jsonData)
obj?.a