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
public struct FixtureType: Codable {
@Element public var wheels: [Wheel]
enum CodingKeys: String, CodingKey {
case wheels = "Wheels"
}
public struct Wheel: Codable {
@XMLAttribute public var name: String
public var slots: [WheelSlot]
enum CodingKeys: String, CodingKey {
case name = "Name"
case slots = "Slot"
}
}
public struct WheelSlot: Codable {
@Attribute public var name: String
@Attribute public var color: ColorCIE
@Attribute public var wheelFilter: String?
@Attribute public var mediaFilename: String?
enum CodingKeys: String, CodingKey {
case name = "Name"
case color = "Color"
case wheelFilter = "Filter"
case mediaFilename = "MediaFileName"
}
}
The decoding works fine with the first data example (the one with at least one Wheel, but fails to load with the empty <Wheels/> or <Wheels></Wheels> tag with error:
DecodingError
▿ typeMismatch : 2 elements
- .0 : Swift.Array<Any>
▿ .1 : Context
▿ codingPath : 2 elements
- 0 : CodingKeys(stringValue: "FixtureType", intValue: nil)
- 1 : CodingKeys(stringValue: "Wheels", intValue: nil)
- debugDescription : "Expected to decode Array<Any> but found SingleKeyedBox instead."
- underlyingError : nil
What changes do I need to make to make the parsing work? I read a few articles that say this library should be able to do this conversion but I cannot seem to make it happen :(.
Thanks for the help!
The text was updated successfully, but these errors were encountered:
I am on XMLCoder 0.17.1 and Xcode 15.4
I have data that looks like this:
but it can also look like this:
My codable structs look like this:
The decoding works fine with the first data example (the one with at least one Wheel, but fails to load with the empty
<Wheels/>
or<Wheels></Wheels>
tag with error:What changes do I need to make to make the parsing work? I read a few articles that say this library should be able to do this conversion but I cannot seem to make it happen :(.
Thanks for the help!
The text was updated successfully, but these errors were encountered: