Tag: json

间断的JSONparsing器失败,为非转义的控制字符

在iPhone应用程序中search某些文本的function。 代码非常简单,我将urlstring传递给twitter api,然后parsing结果。 尽pipeJSONparsing器的一半时间失败,但未转义的控制字符为“0x0”。 下面的代码和完整的错误信息。 – (void)grabData:(NSString *)searchTerm { NSString *urlString = [NSString stringWithFormat:@"http://search.twitter.com/search.json?q=%@&rpp=25",searchTerm]; NSURL *url = [NSURL URLWithString:urlString]; NSLog(@"Created url:%@",url); //Setup and start async download NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [connection release]; [request release]; } – (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { // Store incoming data into […]

使用RestKit 0.20.3来映射json

我试图映射对象通过RestKit 0.20.3,但我有这些日志天知道: 2013-08-12 18:32:08.158 MyAppIphone[848:5703] E restkit.network:RKResponseMapperOperation.m:304 Failed to parse response data: Loaded an unprocessable response (200) with content type 'application/json' 2013-08-12 18:32:08.174 MyAppIphone[848:5703] E restkit.network:RKObjectRequestOperation.m:238 POST 'myUrl' (200 OK / 0 objects) [request=0.1305s mapping=0.0000s total=5.6390s]: error=Error Domain=org.restkit.RestKit.ErrorDomain Code=-1017 "Loaded an unprocessable response (200) with content type 'application/json'" UserInfo=0x1ed5a500 {NSErrorFailingURLKey=myUrl, NSUnderlyingError=0x1ed5b240 "The operation couldn't be […]

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 […]

NSJSONSerialization不工作,NSUTF8StringEncoding正在工作

我已经阅读了文档,教程和其他堆栈问答,并挂断了我如何能够使用NSUTF8StringEncoding显示我的JSON ,但不使用NSJSONSerialization – 这是我需要将数据提取到NSDictionary或NSArray 。 我相信这是从我的url返回的NSData格式的问题? 编辑这是错误:错误域= NSCocoaErrorDomain代码= 3840“操作无法完成。(cocoa错误3840.)”(垃圾在结束。)UserInfo = 0x8aabc30 NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.sampleURL.com"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:15.0]; NSMutableData* responseData = [NSMutableData dataWithCapacity: 0]; – (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { //this works, and have NSLog below responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"string %@", responseString); [responseData appendData:data]; responseData = [[NSMutableData alloc] initWithData:data]; //this is null in […]

将NSArray转换为JSON对象数组

我想从结果数组中创build一个JSON数组对象。 NSMutableArray *resultsArray = [NSMutableArray array]; FMResultSet *resultsSet = [database executeQuery:queryString]; while ([resultsSet next]) { [resultsArray addObject:[resultsSet resultDictionary]]; } 为了澄清,我使用FMDB查询数据库。 然后,我将结果对象存储在resultsArray中。 从这里我想将结果数组转换成JSON数组对象。

我怎样才能在AFNetworking 3.0迁移?

我正在迁移AFNetworking 3.0。 我在AFNetworking中使用AFHTTPRequestOperation,但在最近的更新中删除了它。 我尝试了所有可能的解决scheme。 基本上我需要发布一个JSON头。 我将我的NSDIctionary转换成JSON对象,然后将其添加为string。 这里是我的Header的示例JSON RequestHeader={ "lname" : "sadhsdf", "bday" : "2003-03-13", "age" : "12", "address" : "dsfhskdjgds", "gender" : "M", "cnumber" : "12312412", "fname" : "sadhsdf", "RequestType" : "userregistration", "Email" : "sldjlkasd@sjdhflksdf.com", "status" : "dsfhskdjgds", "Password" : "123456" } RequestHeader是一个NSString,其余的都是NSDictionary。 我如何将它应用于AFNetworking 3.0? 先谢谢你。

JSON文件设置内容types为application / json AFNetworking

我写了一个.json文件,并想用AFNetworking下载。 但AFNetworking抱怨:失败预期的内容types{(“text / json”,“application / json”,“text / javascript”)},得到文本/纯 我的JSON文件test.json { "count-packages": 5, "packages": { "de": { "0": "Wackel Dackel", "1": "Hans Wurst", "2": "Peter Ploes", "3": "Tiffel Toffel", "4": "China Mann" }, "en": { "0": "Wobble dachshund", "1": "Hans Sausage", "2": "Peter Ploes", "3": "Tiffel Potato", "4": "Peking Ente" } } } HTTP/1.1 200 OK […]

如何asynchronous加载JSON(iOS)

我的应用程序使用JSONparsing来自Rails应用程序的信息。 我正在寻找一种asynchronous加载JSON的方式,但是由于我的代码的复杂性,我无法让我的代码与我find的示例一起工作。 我需要做什么来使我的JSON加载asynchronous? 谢谢。 – (void)viewDidLoad { [super viewDidLoad]; NSURL *upcomingReleaseURL = [NSURL URLWithString:@"http://obscure-lake-7450.herokuapp.com/upcoming.json"]; NSData *jsonData = [NSData dataWithContentsOfURL:upcomingReleaseURL]; NSError *error = nil; NSDictionary *dataDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error]; NSArray *upcomingReleasesArray = [dataDictionary objectForKey:@"upcoming_releases"]; //This is the dateFormatter we'll need to parse the release dates NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"]; NSTimeZone […]

Swift:parsingJSON字典值

我试图parsingJSON数据。 我能做的是将JSON数据保存为NSData文件。 然后我可以读它作为NSDictionary,并设置一些值到各自的文本字段。 我不能做的是把这些从JSON值直接到各自的文本字段。 数据的来源是打开天气图。 这对我来说并不重要。 我只需要数据来练习JSONparsing。 无论如何,以下是我所拥有的。 @IBOutlet weak var coordField1: UITextField! @IBOutlet weak var countryField1: UITextField! @IBOutlet weak var ideeField1: UITextField! @IBOutlet weak var nameField1: UITextField! @IBOutlet weak var cntField1: UITextField! @IBOutlet weak var codField1: UITextField! override func viewDidLoad() { super.viewDidLoad() enum JSONError: String, ErrorType { case NoData = "ERROR: no data" case […]

iOS的JSON错误:NSDebugDescription =结束时的垃圾

这是一个非常奇怪的错误,当从我的服务器(它是通过PHP生成的)抓取JSON时,调用时出现此错误: json = [NSJSONSerialization JSONObjectWithData:kivaData options:kNilOptions error:&jsonError]; JSON错误:错误域= NSCocoaErrorDomain代码= 3840“操作无法完成。(cocoa错误3840.)”(垃圾在结束。)UserInfo = 0x178467d00 {NSDebugDescription =垃圾在结束。} 我的(NSData * kivaData)抓住了一切,但它无法parsingJSON。 我已经在http://jsonlint.com/运行我的JSON代码,它出来每次都有效。 它真的很奇怪,因为它可以parsingJSON当我连接到无线上网,但是当我尝试通过手机,它不会工作。 它确实在某些人的手机上通过手机工作,但每次都是这样。