After reading many sources unable to get it there are two issues one : nested data, second name of one property is "Type" which is not accepted by swift saying conflict with .... can someone sort this out or explain straight proper way here is the json response
"IsSuccess": true,
"Message": "Data Returned",
"ResponseData": [
{
"PackageId": 1025,
"PackageName": "Progesterone",
"Price": 00.0,
"DiscountedPrice": 1.0,
"Type": "Test",
"TestPackageGroupId": 3,
"SampleTypeList": [
{
"TestSampleTypeId": "50",
"SampleName": "Serum",
"ColourCode": "#FFB500"
}
]
},
{
"PackageId": 1916,
"PackageName": "24 hour Albumin creatinine ratio (ACR)",
"Price": 00.0,
"DiscountedPrice": 1.0,
"Type": "Test",
"TestPackageGroupId": 3,
"SampleTypeList": [
{
"TestSampleTypeId": "66",
"SampleName": "24 hrs Urine",
"ColourCode": "#212DC1"
}
]
},
how to write data class for above the property "Type" is unaccepted if I use it as it is
struct PriceListAll : Codable
{
let Message: String
let IsSuccess: Bool
let ResponseData: [ResponseData]
}
struct ResponseData:Codable
{
let PackageId: Int
let PackageName: String
let Price: Double
let DiscountedPrice: Double
let Type: String
let TestPackageGroupId: Int
let SampleTypeList: [SampleTypeList]
}
struct SampleTypeList:Codable
{
let TestSampleTypeId: Int
let SampleName: String
let ColourCode: String
}
Error : Type member must not be named 'Type', since it would conflict with the 'foo.Type' expression