如何使用Codable
解析以下响应
{
"Response": {
"ResponseStatus": 1,`enter code here`
"TraceId": "00125bf6-a416-4095-893c-05e05f8c7202",
"Origin": "BOM",
"Destination": "PNQ",
"Results": [
[
{
"IsCouponAppilcable": true,
"IsGSTMandatory": false,
"AirlineRemark": "AI TEST.",
},
{
"IsCouponAppilcable": true,
"IsGSTMandatory": false,
"AirlineRemark": "AI TEST.",
}
]
]
}
}
我想使用Codable
解析"结果"
我试过这个,但坚持如何解析"结果">
struct FlightResponceRequest : Codable {
var Response : FlightResponce
}
struct FlightResponce : Codable {
var ResponseStatus : Int?
var Error : FlightError
var TraceId : String?
var Origin : String?
var Destination : String?
var Results : [FlightResult]?
}
struct FlightError : Codable {
var ErrorCode : Int?
var ErrorMessage : String?
}
struct FlightResult : Codable {
}
你需要让它像这样进行响应,因为你在另一个数组中有一个数组。
var Results : [[FlightResult]]?
然后将键/值解析为FlightResult
结构。