1つのオプションは、特定の値をデコードしようとするラッパータイプを使用することです。nil失敗した場合の保管:
struct FailableDecodable<Base : Decodable> : Decodable {
    let base: Base?
    init(from decoder: Decoder) throws {
        let container = try decoder.singleValueContainer()
        self.base = try? container.decode(Base.self)
    }
}
その後GroceryProduct、Baseプレースホルダーに入力して、これらの配列をデコードできます。
import Foundation
let json = """
[
    {
        "name": "Banana",
        "points": 200,
        "description": "A banana grown in Ecuador."
    },
    {
        "name": "Orange"
    }
]
""".data(using: .utf8)!
struct GroceryProduct : Codable {
    var name: String
    var points: Int
    var description: String?
}
let products = try JSONDecoder()
    .decode([FailableDecodable<GroceryProduct>].self, from: json)
    .compactMap { $0.base } // .flatMap in Swift 4.0
print(products)
// [
//    GroceryProduct(
//      name: "Banana", points: 200,
//      description: Optional("A banana grown in Ecuador.")
//    )
// ]
次に.compactMap { $0.base }、フィルターを使用してnil要素(エラーをスローしたもの)ます。
これにより、の中間配列が作成されますが[FailableDecodable<GroceryProduct>]、これは問題にはなりません。ただし、それを避けたい場合は、キーのないコンテナから各要素をデコードしてアンラップする別のラッパータイプを常に作成できます。
struct FailableCodableArray<Element : Codable> : Codable {
    var elements: [Element]
    init(from decoder: Decoder) throws {
        var container = try decoder.unkeyedContainer()
        var elements = [Element]()
        if let count = container.count {
            elements.reserveCapacity(count)
        }
        while !container.isAtEnd {
            if let element = try container
                .decode(FailableDecodable<Element>.self).base {
                elements.append(element)
            }
        }
        self.elements = elements
    }
    func encode(to encoder: Encoder) throws {
        var container = encoder.singleValueContainer()
        try container.encode(elements)
    }
}
次に、次のようにデコードします。
let products = try JSONDecoder()
    .decode(FailableCodableArray<GroceryProduct>.self, from: json)
    .elements
print(products)
// [
//    GroceryProduct(
//      name: "Banana", points: 200,
//      description: Optional("A banana grown in Ecuador.")
//    )
// ]