Я хочу, чтобы разобрать parseItems, но я не знаю, какObjective C - Разбираем JSon массив
json = [
{
"devicename" : "WL-00000003",
"activated" : "true",
"displayname" : "wit003 ",
"portitems" : {
"port1" : "Smoke Sensor",
"port4" : "",
"port3" : "",
"port6" : "Alarm Siren",
"port2" : "",
"port5" : ""
},
"accountType" : "admin",
"deviceaddress" : "",
"devicestatus" : ""
}
]
Было бы легко, если бы portItems в этом формате "portitems" : ({ })
Я попробовал его с помощью этого кода но он получает ошибку.
NSDictionary *fetchedDictionaryresult = [json objectForKey:@"portItems"];
for (NSDictionary *event in fetchedDictionaryresult)
{
_strPart1 = [event objectForKey:@"port1"];
_strPart2 = [event objectForKey:@"port2"];
_strPart3 = [event objectForKey:@"port3"];
_strPart4 = [event objectForKey:@"port4"];
_strPart5 = [event objectForKey:@"port5"];
_strPart6 = [event objectForKey:@"port6"];
}
Как это сделать?
это JSON словарь – theFool
'portitems'! =' PortItems'. C/Objective-C чувствителен к регистру. – vadian