난 내가 JSON의 같은 문자열로 변환 할 NSDictionary에 값이 :수 없습니다
{
body = "10-feb";
comments = (
);
complete = 1;
"created_at" = "2014-02-09T15:56:01Z";
"due_at" = "2014-01-10 20:00:00 +0000";
"due_on" = "2014-10-02";
id = 439824;
"notification_sent" = 0;
"notify_user" = 0;
"organization_id" = 972;
participants = (
);
reminders = (
);
starred = 0;
"updated_at" = "2014-02-09T15:56:01Z";
"user_id" = 11129;
}
그리고 내가 JSON으로 변환하고있는 방법입니다 :
- (NSString*) jsonStringWithPrettyPrint:(BOOL) prettyPrint str:(NSDictionary *)str {
NSError *error = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:str
options:(NSJSONWritingOptions) (prettyPrint ? NSJSONWritingPrettyPrinted : 0)
error:&error];
if (! jsonData) {
NSLog(@"jsonStringWithPrettyPrint: error: %@", error.localizedDescription);
return @"{}";
} else {
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
}
나는 왜 그것이 항상 변환에 실패하는지 모른다.? 단지 NSDictionary
, NSArray
, NSString
, NSNumber
, 또는 NSNull
를 포함 할 수 있습니다 NSJSONSerialization
에 전달
어떤 오류가 발생하고 있습니까? – Sulthan
'due_at'는'NSDate'입니까? – Wain
예 그것의 NSDate..i 예외적 인 중단 점을 추가했습니다.하지만 그만 멈추지 만 콘솔에서 스택 추적을 얻으려고 시도했지만 아무것도 로그 및 오류가 남아 있지 않습니다. –