Tag: json

如何确定一个NSNumber的真正的数据types?

考虑这个代码: NSNumber* interchangeId = dict[@"interchangeMarkerLogId"]; long long llValue = [interchangeId longLongValue]; double dValue = [interchangeId doubleValue]; NSNumber* doubleId = [NSNumber numberWithDouble:dValue]; long long llDouble = [doubleId longLongValue]; if (llValue > 1000000) { NSLog(@"Have Marker iD = %@, interchangeId = %@, long long value = %lld, doubleNumber = %@, doubleAsLL = %lld, CType = %s, longlong […]

NSData不会接受有效的base64编码的string

我正在iOS(7)cient端实施JSON Web令牌authentication。 这工作很好。 我的应用程序获得令牌,并可以与他们进行身份validation的调用我的服务器。 现在,我希望我的客户端代码检查令牌的到期date,以便知道何时重新进行身份validation。 检查JWT授权令牌上的到期date很简单。 授权令牌是3个base64编码的JSON blob,由'。'分隔。 – 到期时间戳在中间的blob中,在一个叫做ext的字段中。 从Unix时代开始秒。 所以我的代码看起来像这样: – (NSDate*) expirationDate { if ( !_tokenAppearsValid ) return nil; if ( !_parsedExpirationDate ) { // // Token is three base64 encoded payloads separated by '.' // The payload we want is the middle one, which is a JSON dict, with // 'exp' […]

如何在Swift中分析parsing的JSON中的数组?

我正在使用返回JSON的API,看起来像这样 { "boards":[ { "attribute":"value1" }, { "attribute":"value2" }, { "attribute":"value3", }, { "attribute":"value4", }, { "attribute":"value5", }, { "attribute":"value6", } ] } 在Swift中,我使用两个函数来获取并parsingJSON func getJSON(urlToRequest: String) -> NSData{ return NSData(contentsOfURL: NSURL(string: urlToRequest)) } func parseJSON(inputData: NSData) -> NSDictionary{ var error: NSError? var boardsDictionary: NSDictionary = NSJSONSerialization.JSONObjectWithData(inputData, options: NSJSONReadingOptions.MutableContainers, error: &error) as NSDictionary return boardsDictionary […]

AS3的ios:如何序列化一个数组,然后保存它

我有一个multidimentional数组,我想序列化,然后使用SharedObjects保存它。 我尝试了很多东西,但每次都有问题。 JSON:不能有types。 ByteArray:结果不是String,那么SharedObject不想保存它。 可能是SharedObjects不是解决scheme的一部分。 所以我的问题是:有一个简单的解决scheme,以保存光盘上的数组,并检索这个数组? 谢谢。

JSONparsingswift,数组在NSURLSession之外没有任何值

我想在swift中调用一个json webservice,使用下面的代码,并在swift IOS中的tableview中显示它。 /*declared as global*/ var IdDEc = [String]() // string array declared globally //inside viewdidload let url = NSURL(string: "http://192.1.2.3/PhpProject1/getFullJson.php") let task = NSURLSession.sharedSession().dataTaskWithURL(url!) {(data, response, error) in let json1 = NSString(data: data!, encoding: NSUTF8StringEncoding) print("json string is = ",json1) // i am getting response here let data = json1!.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) do […]

将iOS目标c对象转换为JSONstring

我有一个客观的C类, @interface message : NSObject { NSString *from; NSString *date; NSString *msg; } 我有这个消息类的实例的NSMutableArray。 我想使用iOS 5 SDK中的新JSONSerialization API将NSMutableArray中的所有实例序列化为JSON文件。 我怎样才能做到这一点 ? 是通过遍历NSArray中的每个元素的实例来创build每个键的NSDictionary? 有人可以帮助如何解决这个问题的代码? 我无法在Google中取得好成绩,因为“JSON”会将结果向服务器端调用和数据传输倾斜,而不是序列化。 非常感谢。 编辑: NSError *writeError = nil; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:notifications options:NSJSONWritingPrettyPrinted error:&writeError]; NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; NSLog(@"JSON Output: %@", jsonString);

在iOS中实施Google自定义searchAPI

我经历了几个链接,以便find适当的步骤来执行谷歌customsearchapi在iOS应用程序,并花了大约6-7小时在这个过程中。 链接: https://developers.google.com/custom-search/json-api/v1/introduction http://developers.google.com/apis-explorer/#p/customsearch/v1/search.cse.list?q=a&_h=1& https://productforums.google.com/forum/#!topic/customsearch/hT2fnfErVwo Google自定义search:iOS中有403错误 和所有的父亲 所有这些都提供了forms的位和潜能。 有什么地方可以有一个总结,准确的信息,可以帮助在iOS应用程序中实现自定义search?

– :无法识别的select器发送到JSON对象

我正在开发一个iOS 5.0+应用程序与最新的SDK。 我得到这个代码一个非常奇怪的错误: – (NSMutableURLRequest*)setupRequestWithService:(NSString*)service andMethod:(NSString*)method { NSString* url = [NSString stringWithFormat:@"%@%@.svc/%@", serverUrl, service, method]; NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]]; // Set authentication token. NSLog(@"???????????? %@", authenticationToken); if (authenticationToken == nil) NSLog(@"NULL AUTHTOKEN"); if ([authenticationToken isEqual:[NSNull null]]) NSLog(@"NSNULL AUTHTOKEN"); if (request == nil) NSLog(@"NULL REQUEST"); [request addValue:authenticationToken forHTTPHeaderField:REQUEST_HEADER_AUTH_TOKEN]; return request; } 这是我的日志: ???????????? […]

iOS 5 JSONparsingCocoa错误3840的结果

我很难在iOS 5上parsing下面的JSONstring。 {"States": [{"Name": "Arizona","Cities": [{"Name": "Phoenix"}]},{"Name": "California","Cities": [{"Name": "Orange County"},{"Name": "Riverside"},{"Name": "San Diego"},{"Name": "San Francisco"}]},{"Name": "Nevada","Cities": [{"Name": "Las Vegas"}]}]} 这是我的代码: – (void) parseJson { NSError *jsonError = nil; NSData *jsonData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Locations-JSON" ofType:@"rtf"]]; if (jsonData) { NSDictionary *jsonObjects = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&jsonError]; if (jsonError) { NSLog(@"JSON Error: %@", [jsonError localizedDescription]); […]

如何parsingiOS应用程序中的JSON

我得到一个stringforms的Twitter响应, 我需要的是将注释的部分发送到数组, 这里是一个string的例子 [{"geo":null,"coordinates":null,"retweeted":false,… "text":"@KristinaKlp saluditos y besos d colores!"},{"geo":null,"coordinates… 所以我真正需要的是“文本”后的post:“= @KristinaKlp saluditos y besos d colores! 那么,我怎样才能把这个stringparsing出来,这样我就可以得到数组中所有的消息了? 非常感谢!