我有以下json回复
{
"entities": [
{
"columns": [
{
"datatype": "STRING",
"hidden": false,
"name": "key1",
"position": 0,
"title": "barcode",
"value": "0000000117"
},
{
"datatype": "DATE",
"hidden": false,
"name": "key2",
"position": 1,
"title": "order Date",
"value": 1307563633000
}
]
}
]
}
我想将此映射到NSDictionary,其中“name”变量将被视为Key,其余(“datatype”,“hidden”...)将映射到类。
目前我将它们映射到NSSet,在响应中我将它们转换为NSDictionary。
for (SREntity * restEntity in mappingResult.array) {
for (SRColumn *column in restEntity.columnsSet) {
[restEntity.columns setObject:column forKey:column.name];
}
}
但我想知道是否有办法直接进行映射。
类似于:
NSDictionary* columns ->
columns.name : columns.key,
columns : columns.value for columns.key
这有可能吗?