0

I am new to ios,so inorder to get accesstoken, i followed the link http://technogerms.com/login-with-google-using-oauth-2-0-for-ios-xcode-objective-c/ .so in these link they used json.h files are they mandatory.if it is yes then explain me about json github in these link.

3 Answers3

0

Here is the link what you want.

https://github.com/johnezang/JSONKit

Nirav Gadhiya
  • 6,342
  • 2
  • 37
  • 76
0

There is no compulsory to use JSON.h in your project. Now You can use inbuilt apple JSON parser. IF you want to download JSon library then link is

Download JSon file from here

Otherwise you can use this Inbuilt apple JSON Parser by using following method.

 NSDictionary *res = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves || NSJSONReadingMutableContainers error:&myError];

The full code is as below:

 NSString *urlString=[NSString stringWithFormat:@"%@listcontact.php?uid=%@&page=0",LocalPath,appdel.strid]; //---- Add your URL for webservice-----

 NSURL *url = [NSURL URLWithString:urlString];

 NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];

 There are two NSURLConnection request methods AsynchronousRequest and SynchronousRequest.

 (1) For AsynchronousRequest

 [NSURLConnection sendAsynchronousRequest:urlRequest queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
 {
     NSError *error1;
     NSDictionary *res=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error1];
 }];

 (2) For SynchronousRequest

   NSData *GETReply = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:nil error:nil];
   NSError *myError = nil;

   NSDictionary *res = [NSJSONSerialization JSONObjectWithData:GETReply options:NSJSONReadingMutableLeaves error:&myError]; 
Pradhyuman sinh
  • 3,936
  • 1
  • 23
  • 38
0

Use native NSJSONSerialization class, you can find more info on below link,

iOS NSJSONSerialization

How to use NSJSONSerialization

Community
  • 1
  • 1
Vishwa Patel
  • 484
  • 2
  • 10