我正在尝试从服务器解析 JSON,但是每当我使用 AFNetworking 解析器不起作用时,它会返回整个 JSON 而不是将其分离。
我玩弄了 JSON 并注意到了这个 .NET 安全功能
{"d":[JSON INSIDE]}
JSON INSIDE = 包含 3 个数据对象的我的 JSON 数据,此处未显示。导致默认 JSON Parser 仅将整个 JSON 返回为 1。如果我删除 {"d":},它会正确解析为多个部分。但是,服务器返回的数据不能删除 d。AFNetworking 中是否有任何地方可以告诉它忽略 d 部分并仅处理括号内的 [JSON] ?
谢谢,艾伦
更新:在获得“d:”中的数据后,我试图再次重新解析,但我在 NSJSonSerialization 行上获得了 SigAbort。
NSString *innerData = [JSON objectForKey:@"d"];
NSLog(@"Inner Description %@", innerData);
NSError *jsonParsingError = nil;
NSDictionary *requestDictionary = [NSJSONSerialization JSONObjectWithData:[innerData dataUsingEncoding:NSUTF8StringEncoding] options:0 error:&jsonParsingError];
我正在解析的 JSON 示例:
{"d":[{"__type":"RequestSearchedInfo:#ChangeControlService.DataContracts","Description":"testing prod ","DueDate":"","Priority":{"__type":"ComponentInfo:#ChangeControlService.DataContracts","Id":2,"Name":"Medium"},"RequestId":368,"Requestor":{"__type":"ComponentInfo:#ChangeControlService.DataContracts","Id":5863,"Name":"A Person's Name"},"SentDate":"8\/31\/2012 4:28:11 PM","Status":{"__type":"StatusInfo:#ChangeControlService.DataContracts","Id":27,"IsEndState":false,"Name":"Pending Approval"},"System":{"__type":"ComponentInfo:#ChangeControlService.DataContracts","Id":11,"Name":"Internal-Testing"}},{"__type":"RequestSearchedInfo:#ChangeControlService.DataContracts","Description":"testing prod ","DueDate":"","Priority":{"__type":"ComponentInfo:#ChangeControlService.DataContracts","Id":2,"Name":"Medium"},"RequestId":367,"Requestor":{"__type":"ComponentInfo:#ChangeControlService.DataContracts","Id":5863,"Name":"A Persons Name"},"SentDate":"8\/31\/2012 4:27:40 PM","Status":{"__type":"StatusInfo:#ChangeControlService.DataContracts","Id":2,"IsEndState":false,"Name":"Pending Review"},"System":{"__type":"ComponentInfo:#ChangeControlService.DataContracts","Id":11,"Name":"Internal-Testing"}},{"__type":"RequestSearchedInfo:#ChangeControlService.DataContracts","Description":"testin","DueDate":"08\/03\/2012","Priority":{"__type":"ComponentInfo:#ChangeControlService.DataContracts","Id":3,"Name":"High"},"RequestId":29,"Requestor":{"__type":"ComponentInfo:#ChangeControlService.DataContracts","Id":5863,"Name":"A Persons Name"},"SentDate":"8\/2\/2012 1:58:34 PM","Status":{"__type":"StatusInfo:#ChangeControlService.DataContracts","Id":22,"IsEndState":false,"Name":"Acceptance Certification passed, Request to be Closed"},"System":{"__type":"ComponentInfo:#ChangeControlService.DataContracts","Id":11,"Name":"Internal-Testing"}}]}
谢谢!