'how to continue an errored Alamofire json paring that has a missing item in one of the records?

I wanted to know how to continue an errored Alamofire json paring that has a missing item in one of the json's records?

key not found "quoteSourceName" in record number 61 . i still want to continue parsing the same record and the remaining record . and ill do the validation locally

thank you

 gReq = AF.request(gURL1, parameters: ["quoteResponse": "result"])
            gReq.responseData { (gResponse) in
                    guard let data = gResponse.value else {return}
                    do {
                        let str4 = String(data: data, encoding: .utf8)
                     
                        gQuoteParent11 = try JSONDecoder().decode(QuoteParent.self, from: data)
                        } catch {
                            gEr1 = String(describing: error)

this is the structure



struct QuoteParent: Codable {
    var quoteResponse: QuoteResponse
    init() {
        quoteResponse = QuoteResponse()
    }
}

struct QuoteResponse: Codable {
    var error: QuoteError?
    var result: [Stock]?
    init() {
        error = nil
        result = []
    }
}

struct QuoteError: Codable {
    var lang: String?
    var description: String?
    var message: String?
    var code: Int?
    init() {
        lang = ""
        description = ""
        message = ""
        code = 0
    }
}

struct Stock: Codable {
    var language = ""
    var region = ""
    var quoteType = ""
    var typeDisp = ""
    var quoteSourceName = ""
    var triggerable : Bool?
    var customPriceAlertConfidence = ""
    var exchange = ""
    var exchangeTimezoneName = ""
    var exchangeTimezoneShortName = ""
    var gmtOffSetMilliseconds : Double?
    var market = ""
    var esgPopulated : Bool?
    var marketState = ""
    var firstTradeDateMilliseconds : Double?
    var priceHint : Int?
    var preMarketTime : Int?
    var preMarketPrice : Double?
    var regularMarketTime : Int?
    var regularMarketPrice : Double
    var fullExchangeName = ""
    var sourceInterval : Int?
    var exchangeDataDelayedBy : Int?
    var tradeable : Bool?
    var symbol = ""
    init() {
        regularMarketPrice = 0.0000001
    }
}




Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source