-JSONValue失败。错误跟踪为:在iPhone的Google货币转换器中

-JSONValue失败。错误跟踪为:在iPhone的Google货币转换器中,iphone,ios,objective-c,Iphone,Ios,Objective C,我需要实时汇率。我正在使用URL中提供的Google API http:://www.google.com/ig/calculator?hl=en&q=1USD=?INR 每当我使用json解析点击该URL时,响应数据就会变为零。我不知道代码中的确切错误是什么 #define openexchangeURl @"http://www.google.com/ig/calculator?hl=en&q=1USD=?INR" NSURLRequest *request = [NSU

我需要实时汇率。我正在使用URL中提供的Google API

http:://www.google.com/ig/calculator?hl=en&q=1USD=?INR
每当我使用json解析点击该URL时,响应数据就会变为零。我不知道代码中的确切错误是什么

#define openexchangeURl @"http://www.google.com/ig/calculator?hl=en&q=1USD=?INR"

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:openexchangeURl]];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
values =[responseString JSONValue];

这将为您提供生活费:

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://rate-exchange.appspot.com/currency?from=USD&to=INR&q=1"]];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
    NSDictionary *parsedDict = [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL];
    CGFloat value = [parsedDict[@"rate"] floatValue];
    NSLog(@"Value: %f", value);
}];
该api的JSON响应如下所示:

{
  to: "INR",
  rate: 54.8245614,
  from: "USD",
  v: 54.8245614
}

原始请求没有
NSURLConnection
,响应不是有效的JSON(哈希中的每个项没有双引号)。

第二个?查询字符串中应该有一个红旗。仔细检查你的URL。请给出如何解析URL的示例代码,以及{lhs:“1美元”,rhs:“54.0336089印度卢比”,错误:,icc:true}点击该URL后的数据我只需要值为54.0336089听起来像是另一个问题。你是说你不再得到一个nil响应了吗?我已经检查了它在在线json解析器中正确显示的url,但它没有被json库解析,所以我认为它在响应中显示为null,但响应字符串显示正确是现在我得到了相同格式的响应数据,如{lhs:“1美元”,rhs:“54.0336089印度卢比”,错误:,icc:true}如何从54.0336089的价值中获取……有什么想法吗