You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
struct CBORExample: Codable, Equatable {
var m: [[Int]?]? = nil
}
func test() {
let obj = CBORExample(m: [[1,2], nil, [3,4]])
do {
let encoder = CBOREncoder()
let encodedData = try encoder.encode(obj) // This works fine, checked the result with cbor.me
let decoder = CBORDecoder()
let decoded: CBORExample? = try decoder.decode(CBORExample.self, from: encodedData) // This fails
print("Decoded: \(String(describing: decoded))")
} catch {
print("\(error)")
}
}
Project Version
latest
The OS/Variant where this issue occurs.
iOS
macOS
tvOS
watchOS
Mac Catalyst
Other (Please specify in "Additional Context" section)
The version of Xcode that was used when this issue appeared.
14.3.1
What was the environment in which the issue appeared?
CBORCoding.xcodeproj
Package.swift
Carthage
CocoaPods
Swift Package Manager
Other (Please specify in "Additional Context" section)
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Expected Behavior
Decoding null values to nil should work inside an array.
Actual Behavior
Cannot decode and I get the following error:
valueNotFound(Swift.Optional<Swift.Array<Swift.Int>>, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "m", intValue: nil), CodingKey(stringValue: "Index 1", intValue: 1), CodingKey(stringValue: "Index 1", intValue: 1)], debugDescription: "Expected Optional<Array> but found null instead.", underlyingError: nil))
Steps To Reproduce
Here is simple sample code:
Project Version
latest
The OS/Variant where this issue occurs.
The version of Xcode that was used when this issue appeared.
14.3.1
What was the environment in which the issue appeared?
Additional Context
No response
The text was updated successfully, but these errors were encountered: