"documenttypes": [{
"documentname": "DNC Format",
"mandatory": "0",
"limitnumber": "2",
"supportingfiles": {
"document": [{
"type": "DNC Format",
"displayname": "DNC_Format"
}]
}
},
{
"documentname": "Joint Life Addendum",
"mandatory": "0",
"limitnumber": "3",
"supportingfiles": {
"document": [{
"type": "Joint Life Addendum",
"displayname": "Joint_Life_Addendum"
}]
}
},
{
"documentname": "Age proof of Child",
"mandatory": "0",
"limitnumber": "3",
"supportingfiles": {
"document": [{
"type": "Age proof of Child",
"displayname": "Age_proof_of_Child"
}]
}
},
{
"documentname": "Permanent Address Proof of Proposer",
"mandatory": "0",
"limitnumber": "4",
"supportingfiles": {
"document": [{
"type": "AADHAR Card",
"displayname": "AADHAR_Card"
},
{
"type": "Aadhar Card letter",
"displayname": "Aadhar_Card_letter"
},
{
"type": "KMBL KYC ",
"displayname": "KMBL_KYC "
},
{
"type": "Driving License",
"displayname": "Driving_License"
}
]
}
}]
我将类型键提取到 typeArray 中,但我需要提取为数组数组:
if let personArray = jsonResult.value(forKey: "documenttypes") as? NSArray {
for (_, element) in personArray.enumerated() {
if let element = element as? NSDictionary {
let id = element.value(forKey: "documentname") as! String
self.documentnameArr.append(id)
let files = element.value(forKey: "supportingfiles") as! NSDictionary
if let personArray = files.value(forKey: "document") as? NSArray {
for (_, element) in personArray.enumerated() {
if let element = element as? NSDictionary {
if let myArr = element.value(forKey: "type"){
self.typeArr.append(myArr as! String)
}
}
}
}
}
}
我正在获取所有类型键值,typeArr
但我需要像数组数组这样的值:
[["DNC FORMAT"],["Joint Life Addendum"],[儿童年龄证明],[AADHAR Card,Aadhar Card letter,KMBL KYC ,Driving License]]