104

As a learning experience, I want to make an iPhone application that calls a webserver/webservice, retrieves a JSON response, and uses that response to populate the rows of a UITableView (assuming it converts the JSON into an NSArray first).

Anyone know of anything that might be useful?

Bhavin Ramani
  • 3,221
  • 5
  • 30
  • 41
Casey Flynn
  • 13,654
  • 23
  • 103
  • 194

6 Answers6

164

You will love this framework.

And you will love this tool.

For learning about JSON you might like this resource.

And you'll probably love this tutorial.

unicorn_crack
  • 1,059
  • 1
  • 8
  • 19
Todd Hopkinson
  • 6,803
  • 5
  • 32
  • 34
  • You're absolutely right about me loving that too @icnivad, thanks a lot for the lead this is very useful. – Casey Flynn Apr 28 '11 at 03:51
  • . Tutorial you mentioned requires DMG file but I could not find any DMG file on Link you mentioned for framework. that link directs on github and contains a zip file with various classes and examples but I dont understand which part I need to insert in my project. Can you please help me? – alekhine Nov 04 '11 at 09:35
  • 2
    Yeah, that project moved to github. Get it here: https://github.com/stig/json-framework/. – Todd Hopkinson Nov 04 '11 at 19:54
  • You'll also probably love hurl.it – Caspar Harmer Mar 26 '12 at 07:49
  • That SBJson thing would be nice if it built. Fails for me with 44 errors in Xcode 4 in OS X Lion. – Sarah Vessels Jul 20 '12 at 17:04
  • I do love this answer. And I did love the way it was written. I will definitely love to vote it up now. ;) – driechel Apr 30 '13 at 10:56
57

As of iOS 5.0 Apple provides the NSJSONSerialization class "to convert JSON to Foundation objects and convert Foundation objects to JSON". No external frameworks to incorporate and according to benchmarks its performance is quite good, significantly better than SBJSON.

darrinm
  • 9,117
  • 5
  • 34
  • 34
6
SBJSON *parser = [[SBJSON alloc] init];

NSString *url_str=[NSString stringWithFormat:@"Example APi Here"];

url_str = [url_str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:url_str]];

NSData *response = [NSURLConnection sendSynchronousRequest:request  returningResponse:nil error:nil];

NSString *json_string = [[NSString alloc] initWithData:response1 encoding:NSUTF8StringEncoding]

NSDictionary *statuses = [parser2 objectWithString:json_string error:nil];

 NSArray *news_array=[[statuses3 objectForKey:@"sold_list"] valueForKey:@"list"];

    for(NSDictionary *news in news_array)
{

    @try {
        [title_arr addObject:[news valueForKey:@"gtitle"]];    //values Add to title array

    }
    @catch (NSException *exception) {

        [title_arr addObject:[NSString stringWithFormat:@""]];
    }
chandrika
  • 394
  • 4
  • 12
4

This is the tutorial I used to get to darrinm's answer. It's updated for ios5/6 and really easy. When I'm popular enough I'll delete this and add it as a comment to his answer.

http://www.raywenderlich.com/5492/working-with-json-in-ios-5

http://www.touch-code-magazine.com/tutorial-fetch-and-parse-json-in-ios6/

Avisek Chakraborty
  • 8,229
  • 10
  • 48
  • 76
cloudsurfin
  • 2,467
  • 2
  • 25
  • 29
4

try out with this fastest JSON framework JSONKit. it's faster than normal JSON framework.

Hiren
  • 12,720
  • 7
  • 52
  • 72
1

Here's a link to my tutorial, which walks you through :

  • creating a JSON WCF Web Service from scratch (and the problems you'll want to avoid)
  • adapting it to read/write SQL Server data
  • getting an iOS 6 app to use the JSON servies.
  • using the JSON web services with JavaScript

http://mikesknowledgebase.com/pages/Services/WebServices-Page1.htm

All source code is provided, free of charge. Enjoy.

Mike Gledhill
  • 27,846
  • 7
  • 149
  • 159