iPhone JSON framework for the parsing and generation of JSON data

A JSON library for the iPhone. For more information and a tutorial visit http://www.mobileorchard.com/tutorial-json-over-http-on-the-iphone/

Get the latest version of the JSON framework

Use the JSON framework:

- (void)viewDidLoad {	
	responseData = [[NSMutableData data] retain];
	NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.server.com/jsonresponse"]];
	[[NSURLConnection alloc] initWithRequest:request delegate:self];
        [super viewDidLoad];
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
	[connection release];
	NSString *responseString = [[NSString alloc]
                initWithData:responseData encoding:NSUTF8StringEncoding];
	NSDictionary *dict = [responseString JSONValue];
	[responseData release];
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
	[responseData setLength:0];
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
	[responseData appendData:data];
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {;
	NSLog([NSString stringWithFormat:@"Connection failed: %@", [error description]]);

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>