I have to fetch the reqid and appprimaycontact from ssoSummaryVOMap part in the json the structure of json is below .
在获取json时,我收到错误
2016-05-16 15:18:48.360 Sip[30390:317309] -[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x7f7fc2e2e060
2016-05-16 15:18:48.377 Sip[30390:317309] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x7f7fc2e2e060'
我的json数据是
json{
appExIntgRequestId = 0;
appQuestionnaireStatus = "E1 Pending";
description = "Questionnaire retrieved successfully";
isAdminRole = 0;
isSuperAdminRole = 0;
logoutUrl = "https://ssointrad.dev.ipc.us.aexp.com/SSOI/request?request_type=un_logoff&SSOURL=";
quesSubmitType = 0;
requestDeleted = 0;
returnCode = 0;
saveBeforeLogoff = 0;
ssoQuestionnaireGeneralInfoVO = {
aimId = 200109736;
appPrimaryContactCountryCode = 1;
appPrimaryContactEmail = "ssoipAppUser@aexp.com";
appPrimaryContactName = "ssoipApp User";
appPrimaryContactPhone = 2232323123;
appPrimaryContactPhone1 = 223;
appPrimaryContactPhone2 = 232;
appPrimaryContactPhone3 = 3123;
appSecondaryContactCountryCode = "<null>";
appSecondaryContactEcn = "<null>";
appSecondaryContactEmail = "ssoipnonadmin@aexp.com";
appSecondaryContactName = "ssoip NonAdmin";
appSecondaryContactPhone = "<null>";
appSecondaryContactPhone1 = "<null>";
appSecondaryContactPhone2 = "<null>";
appSecondaryContactPhone3 = "<null>";
applicationName = "App Dir ITGC";
engagementNo = 1264281;
projMasterDC = PTY123567Y;
requestId = 41458;
ssoProjManagerEmail = "ssoip.Admin5@aexp.com";
ssoProjManagerName = "ssoip Admin5";
ssoTechLeadEmail = "ssoip.Admin4@aexp.com";
ssoTechLeadName = "ssoip Admin4";
};
ssoQuestionnaireSpecificDetailsVO = {
appAjaxCalls = 0;
appAliasName = "SIP_R6PerfTesting_Internet_51206";
appAuthnTypeId = "-1";
appBranding = 0;
appChangeDetails = "";
appChangeReasonId = "-1";
appCoarseAuthorization = "-1";
appCustomPages = 0;
appDependencyAimIdList = {
};
appDependencyAll = "<null>";
appDependencyid = 0;
appDomainId = 2;
appE1ImplDate = "05/23/2016";
appE2ImplDate = "07/11/2016";
appE3ImplDate = "08/09/2016";
appExclusiveRegistration = 0;
appExistingRegAimIdAll = "<null>";
appExistingRegServiceIdAll = "<null>";
appExistingRegistration = 0;
appHostingenvironmentId = 1;
appInternalHostingEnvId = 1;
appLocaleAll = "en_US|";
appLocaleList = (
"en_US"
);
appProviderType = "-1";
appRATypeId = 4;
appReleaseEnvironmentE1 = 2;
appReleaseEnvironmentE2 = 3;
appReleaseEnvironmentE3 = 4;
appSSOIntegrated = 0;
appSamlCompatible = "-1";
appSamlVersion = 0;
appServersProvisioned = 0;
appServiceIdAimIdList1 = "<null>";
appServiceIdAimIdList2 = "<null>";
appSsoPassParameters = 1;
appUserDomainId = 2;
appUserOrigination = 1;
appUserTypeAll = "<null>";
appUserTypeList = (
);
appWebServerBitCompilation = "-1";
appWebServerOS = Others;
appWebServerOSBitCompilation = "-1";
appWebServerType = "<null>";
appaimidserviceid = {
};
};
ssoSummaryVOMap = {
41178 = {
aimId = 0;
aliasName = "Alias_test_783_new_Testing";
appName = "<null>";
**appPrimaryContact = "<null>";**
domainName = IntErnet;
engagementNo = "<null>";
hostingEnv = "Internally Hosted(Amex)";
reqDate = "<null>";
**reqId = 41178;**
ssoProjManager = "<null>";
ssoTechLead = "<null>";
status = "<null>";
};
41227 = {
aimId = 0;
aliasName = "Alias_new_testing_243721";
appName = "<null>";
**appPrimaryContact = "<null>";**
domainName = IntrAnet;
engagementNo = "<null>";
hostingEnv = "Internally Hosted(Amex)";
reqDate = "<null>";
**reqId = 41227;**
ssoProjManager = "<null>";
ssoTechLead = "<null>";
status = "<null>";
};
41259 = {
aimId = 0;
aliasName = "Alias_test_848_testing";
appName = "<null>";
**appPrimaryContact = "<null>";**
domainName = IntrAnet;
engagementNo = "<null>";
hostingEnv = "Internally Hosted(Amex)";
reqDate = "<null>";
**reqId = 41259;**
ssoProjManager = "<null>";
ssoTechLead = "<null>";
status = "<null>";
};
41302 = {
aimId = 0;
aliasName = "Alias_new_testing_4563";
appName = "<null>";
appPrimaryContact = "<null>";
domainName = IntrAnet;
engagementNo = "<null>";
hostingEnv = "Internally Hosted(Amex)";
reqDate = "<null>";
reqId = 41302;
ssoProjManager = "<null>";
ssoTechLead = "<null>";
status = "<null>";
};
};
status = "PROC_EXEC_SUCCESS";
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"Did Finish");
// Do something with responseData
NSString *strData=[[NSString alloc] initWithData:_responseData encoding:NSASCIIStringEncoding];
NSData *jsonData = [strData dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
NSLog(@" json%@", json);
NSArray* info = [json objectForKey:@"ssoSummaryVOMap"];
NSLog(@" ssoSummaryVOMap%@", info);
for(int i=0; i<info.count; i++){
NSMutableDictionary * requestId= [[NSMutableDictionary alloc]init];
requestId = [info objectAtIndex:i];
}
NSLog(@" the name is %@ ", _appPrimaryContact);
NSLog(@" the reqid is %@", _reqId);
NSLog(@" the status is %@", _status);
i tried everything to get to the solution but no luck .
Please help .
答案 0 :(得分:1)
尝试下一步:
NSDictionjary *yourJSON = [json objectForKey:@"ssoSummaryVOMap"];
id object = [yourJSON objectForKey:@"41178"];
答案 1 :(得分:1)
很容易就可以获得值使用代码..
// ssoSummaryVOMap key denotes a parent dictionary
NSDictionjary *yourJSON = [json objectForKey:@"ssoSummaryVOMap"];
// same 41178 key also denotes a dictionary which is sub dict of previous
NSDictionjary *subDict = [yourJSON objectForKey:@"41178"];
// you can easily get the particular value now
NSString *value = [subDict objectForKey:@"aliasName"];
NSLog(@"response = %@",value);
快乐的编码..
答案 2 :(得分:0)
NSArray *array = @[@{@"Key1" : @"Value1"}, @{@"Key2" : @"Value2"}, @{@"Key3" : @"Value3"}];
for (NSDictionary *dict in array) {
NSLog(@"%@", dict.allKeys);
for (NSString *key in dict.keyEnumerator) {
NSLog(@"Key: %@, Value %@", key, dict[key]);
}
}
答案 3 :(得分:0)
重写这些行
sqlalchemy.exc.UnboundExecutionError: Could not locate a bind configured on mapper Mapper|Question|question or this Session
这样的事情......
NSArray* info = [json objectForKey:@"ssoSummaryVOMap"];
NSLog(@" ssoSummaryVOMap%@", info);
for(int i=0; i<info.count; i++)
{
NSMutableDictionary * requestId= [[NSMutableDictionary alloc]init];
requestId = [info objectAtIndex:i];
}
请注意,您应该添加一些感知检查代码。