Ich habe NSJSONSerialization
für die Konvertierung NSdata
in einer iOS-Anwendung verwendet.NSJSONSerialization: Fehler "Kein Wert"
Hier ist mein Code:
[NSURLConnection sendAsynchronousRequest:req queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{ // getting 1 byte data
if (error)
{
}
else
{
NSError *errorData = nil;
id responseObject1 = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&errorData];
// error : Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (No value.) UserInfo=0x78e43130 {NSDebugDescription=No value.}
if (!errorData)
{
} ......
}
}
Hier meine Json Daten sind:
{"root":{"status":true,"info":"Inserted"}}
Und ich bekomme 1 Byte von Daten nach Anforderung sendet.
Aber es konvertiert keine Daten. Es gibt einen "Kein Wert" -Fehler bei der Parsing-Zeit:
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (No value.) UserInfo=0x78e43130 {NSDebugDescription=No value.}
Bitte helfen Sie mir: Was ist das Problem?
ein Byte Daten bekommen? Du meinst das [Datenlänge] = 1? "Ja wirklich?" Welcher? Wie soll es JSON nach der Antwort sein? – Larme
Versuchen Sie: '[NSJSONSerialization JSONObjectWithData: Datenoptionen: 0 Fehler: & FehlerData];' –
Wenn Sie 'NSLog (@"% @ ", Daten)', was bekommen Sie? –