JSON decoding in Swift Failure

Just ran into this error when trying to decode some JSON in Swift and the error message had me stumped for too long despite being trivial so I thought I’d commit it to memory. The JSON looked like this: And here’s the Swift struct I was trying to use to decode it: The problem is in the declaration of bar in Foo, it is not an array of Bar, it is just a Bar. So the declaration should be: Then this test case will work: