我有JSON,有时会显示有时是简单对象的数组
"ownersPeriod" : [
{
"dateTo" : "2013-06-17",
"dateFrom" : "2012-09-15"
},
{
"dateTo" : "2016-06-30",
"dateFrom" : "2013-06-17"
},
{
"dateTo" : "",
"dateFrom" : "2016-06-30"
}
],
"ownersPeriod" : {
"dateTo" : "",
"dateFrom" : "2008-03-29"
},
如何将简单对象映射或转换为此类型数组
我使用对象映射器映射数组
public var ownersPeriodArray: [Model] = []
您可以在这里尝试此代码:http://online.swiftplayground.run/