嗨,我正在制作从网页获取 json 的应用程序,但它没有使用 touchJson(框架、库、类)将 jsonData 转换为 Dict
杰森
{SFP:[{"Group":"Oil"},{"Group":"Sugar"}]}
编码
NSStringEncoding *Encoding;
NSError *Error;
NSURL *PriceURL = [NSURL URLWithString:@"http://xxx.co/SFP/?Q=P1"];
NSString *JsonString = [[NSString alloc] initWithContentsOfURL:PriceURL usedEncoding:Encoding error:&Error];
NSData *JsonData = [JsonString dataUsingEncoding:NSUTF32BigEndianStringEncoding];
NSDictionary *Dict = [[[CJSONDeserializer deserializer] deserializeAsDictionary:JsonData error:&Error] retain];
NSArray *Rows = [Dict objectForKey:@"SFP"];
NSLog(@"%@", JsonString);
NSLog(@"%@", JsonData);
NSLog(@"%@", Dict);
康索尔
2012-08-05 14:49:02.794 SFP[23791:f803] {SFP:[{"Group":"Oil"},{"Group":"Sugar"}]}
2012-08-05 14:49:02.795 SFP[23791:f803] <0000007b 00000053 00000046 00000050 0000003a 0000005b 0000007b 00000022 00000047 00000072 0000006f 00000075 00000070 00000022 0000003a 00000022 0000004f 00000069 0000006c 00000022 0000007d 0000002c 0000007b 00000022 00000047 00000072 0000006f 00000075 00000070 00000022 0000003a 00000022 00000053 00000075 00000067 00000061 00000072 00000022 0000007d 0000005d 0000007d>
2012-08-05 14:49:02.795 SFP[23791:f803] (null)