Thursday, June 23, 2011

Json Parsing Request

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...

No comments:

Create a list in SwiftUI with sticky section headers

 Sample Code import SwiftUI struct ContentView : View {     @State var isCustomViewControllerDisplayed = false     @State private va...