Closed stonedauwg closed 5 years ago
Thanks @stonedauwg, this looks to be already fixed in master
, which I've just verified by additional tests in #66. I plan to release XMLCoder 0.3 ASAP, which will contain this fix, but please feel free to reopen the issue if there's still anything missing.
With a simple struct:
struct ProudParent : Codable {
var myChildAge: [Int]
}
var theparent = ProudParent()
theparent.myChildAge = [2,3]
<ProudParent><myChildAge>2</myChildAge><myChildAge>3</myChildAge></ProudParent>
The encoding always works, but if there is only one element in the myChildrenAgesCollection Int array it will fail to decode with the error: "Expected to decode Array but found a string/data instead".
EX: this will encode but fail to decode back
var theparent = ProudParent()
theparent.myChildAge = [2]
<ProudParent><myChildAge>2</myChildAge></ProudParent>
Surely something as simple as that structure can be decoded. What trick am I missing?