jsonと目的のcでいくつかの問題に直面しています。Atm 私は 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 ?
どうも