整天被这个困扰,并寻求帮助尽快解决这个问题。任何帮助都会很棒。谢谢 :-)
缺少的引号
从网上得到了这个 AFJSONRequestOperation 请求,除了一个关键的错误之外,它工作得很好:一些键缺少那里的引号值 = 不能使用它们!显然,AFNetworking 背景中正在进行一些解析,因为这些值按字母顺序返回 + 某些值上的一些 qoutes 的“修剪”。但我只想要“原样”的网络数据......
格式应该是这样的; theKey = "theValue";
但有时它看起来像这样; 键=值;// 注意值周围缺少的引号
网络输出 json:
我还检查了来自服务器的 json 格式是否正确,输出如下所示;
{"results":[{"ID":"3","Row_state":"Visible","CustName":"Customer Name","CustReferens":"Customer Referens","CustReferensMobil":"123456mob","CustNotes":"Customer Notes","Tel":"123456tel","Fax":"123456fax","Web":"www.example.se","Mail":"info@example.se","Street":"The road 5","Zip":"11122","City":"Stockholm","Products":"","Images":"","Logo":"myLogo.jpg","Text":"A lot of text goese here...","Seller":"","Favorite":"YES"},
在应用程序中,我得到了这个结果;
results = (
{
City = Stockholm; // Note the missing quotes around the value
CustName = "Customer Name";
CustNotes = "Customer Notes";
CustReferens = "Customer Referens";
CustReferensMobil = 123456mob; // Note the missing quotes around the value
Favorite = YES; // Note the missing quotes around the value
Fax = 123456fax; // Note the missing quotes around the value
ID = 3; // Note the missing quotes around the value
Images = "";
Logo = "myLogo.jpg";
Mail = "info@example.se";
Products = "";
"Row_state" = Visible; // Now key got quotes + Note the missing quotes around the value
Seller = "";
Street = "The road 5";
Tel = 123456tel; // Note the missing quotes around the value
Text = "A lot of text goese here...";
Web = "www.example.se";
Zip = 11122; // Note the missing quotes around the value
},
而不是这个预期的结果(所有带有引号的键值);
results = (
{
City = "Stockholm";
CustName = "Customer Name";
CustNotes = "Customer Notes";
CustReferens = "Customer Referens";
CustReferensMobil = "123456mob";
Favorite = "YES";
Fax = "123456fax";
ID = "3";
Images = "";
Logo = "myLogo.jpg";
Mail = "info@example.se";
Products = "";
"Row_state" = Visible;
Seller = "";
Street = "The road 5";
Tel = "123456tel";
Text = "A lot of text goese here...";
Web = "www.example.se";
Zip = "11122";
},
我的代码;
NSURL *myUrl = [NSURL URLWithString:@"http://example.se/api.lasso"];
NSURLRequest *request = [NSURLRequest requestWithURL:myUrl];
AFJSONRequestOperation *operation;
operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request
success:^(NSURLRequest *req, NSHTTPURLResponse *responce, id jsonObject) {
NSLog(@"JSON Responce ÅF: %@",jsonObject);
// Add result (an array from JSON) to NSMutableArray
_restFeed = [jsonObject objectForKey:@"results"];
NSLog(@"RestA-OListTVC > ViewDidload > AFN ÅF: _restFeed count = %i",[_restFeed count]);
// Reload table with new data
[self.tableView reloadData];
}
failure:^(NSURLRequest *req, NSHTTPURLResponse *responce, NSError *error, id jsonObject) {
NSLog(@"Recieved an HTTP %d", responce.statusCode);
NSLog(@"The error was: %@",error);
}];
[operation start];