afnetworking返回数据的是os dispatch data 没办法进行解析
转换方法 :
NSString*receiveStr = [[NSStringalloc]initWithData:responseObjectencoding:NSUTF8StringEncoding];
NSData* data = [receiveStrdataUsingEncoding:NSUTF8StringEncoding];
指定转换成的类型 这里看作字典 可以拿来解析了
NSDictionary*jsonDict = [NSJSONSerializationJSONObjectWithData:dataoptions:NSJSONReadingMutableLeaveserror:nil];
通用方法 :用于将服务器返回的responseObject 转成可解析的json
1.
NSError*error;
NSData*jsonData = [NSJSONSerializationdataWithJSONObject:respondObjectoptions:NSJSONWritingPrettyPrintederror:&error];
id json = [NSJSONSerializationJSONObjectWithData:jsonDataoptions:NSJSONReadingMutableLeaveserror:nil];
return json;
2.
NSString *receiveStr = [[NSString alloc] initWithData:respondObject encoding:NSUTF8StringEncoding];
NSData * mm = [receiveStr dataUsingEncoding:NSUTF8StringEncoding];
id json = [NSJSONSerialization JSONObjectWithData:mm options:NSJSONReadingMutableLeaves error:nil];
returnjson;