How to get and Insert data in JSON Parsing in IOS6
I am trying to insert data in to JSON link and retrieve data from JSON link by using JSONParser.
How can I use JSON Parser without adding JSON frame work in IOS6.
First you need to Import JSON Files you'll get that from here
Then if you are using POST method then do Following :
NSString *myRequestString = [NSString stringWithFormat:@"u=%@&p= %@",strUname,strPassword];
myRequestString=[myRequestString stringByReplacingOccurrencesOfString:@" " withString:@""];
NSData *myRequestData = [NSData dataWithBytes:[myRequestString UTF8String] length:[myRequestString length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString: @"Your Webservice URL"]];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:myRequestData];
NSData *returnData = nil;
returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
NSDictionary *myDic = [NSJSONSerialization JSONObjectWithData:returnData options:NSJSONReadingMutableLeaves error:nil];
If You are using GET method then use the Following :
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"Your WebService with Parameters in URL"]]];
NSDictionary *MyDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
Hope This will Help.