0
我正在面臨與json和目標c的一些問題。 Atm我使用sbJson框架(我可以改變框架,如果有人告訴我這樣做!),我不能解析一個JSON數組。iphone與sbjson框架無法解析json數組
這就是我想要解析JSON,
{"JsonEventosResult":
[
{"nombre":"Venta de Reposición N°13","id":34,"fecha":"16/09/2011"},
{"nombre":"evento rose","id":37,"fecha":"04/10/2011"},
{"nombre":"Prueba PhoneGap","id":40,"fecha":"23/11/2011"}
]
}
這是我的iphone代碼:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[responseData release];
NSError *error;
SBJSON *json = [[SBJSON new] autorelease];
NSArray *luckyNumbers = [json objectWithString:responseString error:&error];
[responseString release];
if (luckyNumbers == nil)
label.text = [NSString stringWithFormat:@"JSON parsing failed: %@", [error localizedDescription]];
else {
NSMutableString *text = [NSMutableString stringWithString:@"Lucky numbers:\n"];
for (int i = 0; i < [luckyNumbers count]; i++)
[text appendFormat:@"%@\n", [luckyNumbers objectAtIndex:i]];
label.text = text;
}
}
我得到的錯誤是luckyNumbers是0對象的數組。
我從http://mobileorchard.com/tutorial-json-over-http-on-the-iphone/得到的樣本。
那麼問題在哪裏? JSON我得到表單服務或框架?
thx