I have DataModel
data type:
class DataModel: Decodable {
var data : Any?
var name : String?
}
server json:
{
"data":"success",
"name":"john"
}
or
{
"data": {
"result": {
"shopcode": 0,
"shopname": ""
}
},
"name": "john"
}
the data
property I not sure type, sometime is [String: Any]
or String
or null
.
I search some answer, but it not I want, so please don't set question [duplicate]
How to decode a property with type of any arbitrary JSON dictionary in Swift 4 decodable protocol
Any when decoding JSON with Codable?
How to solve this? Have any way let data property decoder to [String: Any]
, String
, nil
?
English is not my native language; please excuse typing errors