PPJSONSerialization
PPJSONSerialization copied to clipboard
Mappy of [AnyObject]() does not work.
I have a json where am array can be either, [String] or [Dictionary], so i decided to use [AnyObject], but PPJSONSerialization fails to map and the array has always 0 values. Can someone please guide me on this.
below is the json
{
"assetfields": [
{
"text": "Invoice Files",
"value": [
{
"name": "agri.png",
"fileid": 560,
"url": "/tpfileservlet?fileID=560&mode=assetfieldfile"
},
{
"name": "bingo-logo.png",
"fileid": 559,
"url": "/tpfileservlet?fileID=559&mode=assetfieldfile"
}
],
"assetfieldid": 111,
"type": "File Upload"
},
{
"text": "upccode",
"value": [
"upccode111111111"
],
"assetfieldid": 110,
"type": "Text"
},
{
"text": "Installation Date",
"value": [
"Mar 31 2016",
"00:00"
],
"assetfieldid": 109,
"type": "Date / Time"
},
{
"text": "Serial Number",
"value": [
"123"
],
"assetfieldid": 104,
"type": "Text"
}
],
"assetclassid": 75,
"name": "Lenovo Laptop",
"assetsubclassid": 75,
"assetfamilyid": 73,
"assetid": 115
}
and my class is
class AssetField: PPJSONSerialization {
var text: String?
var type: String?
var assetfieldid: NSNumber?
var value = [AnyObject]()
}