NSDictionary *o1 = [NSDictionary dictionaryWithObjectsAndKeys:
@"some value", @"key1",
@"another value", @"key2",
nil];
NSDictionary *o2 = [NSDictionary dictionaryWithObjectsAndKeys:
@"yet another value", @"key1",
@"some other value", @"key2",
nil];
NSArray *array = [NSArray arrayWithObjects:o1, o2, nil];
NSString *jsonString = [array JSONRepresentation];
NSLog(@"%@",jsonString);
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://sample.com"]];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[jsonString dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
NSLog(@"%@",connection);
Note:
Before write code you have to include JSON Files. it is available
If you have any doubt ask me...
@"some value", @"key1",
@"another value", @"key2",
nil];
NSDictionary *o2 = [NSDictionary dictionaryWithObjectsAndKeys:
@"yet another value", @"key1",
@"some other value", @"key2",
nil];
NSArray *array = [NSArray arrayWithObjects:o1, o2, nil];
NSString *jsonString = [array JSONRepresentation];
NSLog(@"%@",jsonString);
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://sample.com"]];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[jsonString dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
NSLog(@"%@",connection);
Note:
Before write code you have to include JSON Files. it is available
If you have any doubt ask me...
No comments:
Post a Comment