-3

As I'm a newbie in iOS development, please help me to parse the JSON output.

My JSON output:

{"sbi":[{"Emp_Id":1001,"Emp_Name":"James","Designation":"Manager","Skills":["C,C++"]},{"Emp_Id":1002,"Emp_Name":"John","Designation":"Asst.Manager","Skills":["Java,PHP"]},{"Emp_Id":1003,"Emp_Name":"Joe","Designation":"Chief Manager","Skills":["Oracle,HTML"]}]}

When we launch an app, I should get sbi on the first view and if I select that particular row, I should get all the details related to sbi on the next view, i.e. EmpId, EmpName, Designation, Skills, ...

Thanks in advance.

Neeku
  • 3,646
  • 8
  • 33
  • 43
santosh
  • 77
  • 1
  • 8

3 Answers3

1

Parse the json to a dictionary object with

NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:yourJson options:0 error:nil];
Alex Andrews
  • 1,498
  • 2
  • 19
  • 33
0

Please refer following link to Json parsing Demo.It will help you to learn Json parsing.

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

Vipul
  • 130
  • 8
0
    -(void)Startconnection:(NSString *)urlString
{
   NSLog(@"%@",urlString); 
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:"your url string "]];
 connetion1=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self] ;
    webData = [NSMutableData data];

}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    [webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    [webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
 //   [ShowAlert showMyAlert:@"Network Alert" :@"No Internet connection detected"];

}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{

    NSError *myError = nil;
    responceDic=nil;
 responceDic = [NSJSONSerialization JSONObjectWithData:webData options:NSJSONReadingMutableLeaves error:&myError];

    NSLog(@"%@",responceDic  );
}

In the .h file declare NSXMLParserDelegate delegate

@interface webservice : NSObject<NSXMLParserDelegate>
{

    NSMutableData *  webData;
    NSString *currentData;
    NSURLConnection * connetion1;

}
Vivek Yadav
  • 1,117
  • 10
  • 14
  • 2
    Get the responce NSLog(@"%@",[[responceDic objectforkey:@"sbi"] objectforkey:@"Emp_Id"]); –  Jul 14 '14 at 12:06