JSON Framework for IOS

Now let us discuss how to integrate JSON framework in IOS applications.
Step-1 :
have a look at the features Introductions at google’s home page
Step-2 :
download and extract the source from GitHub
Step-3 :
Rename directory named Classes to JSON.
Step-4 :
This step will involve some small individual steps
  • Move the renamed directory to Classes directory of target project
  • Open target project choose Classes group
  • Now right click and choose Add -> Existing files and add JSON to it.
Step-5 : Usage
  • Import json.h in the class you wish to use json.
  • For IOS to JSON you can call JSONRepresentaion on any object
        NSArray *arr=[NSArray arrayWithObjects:@"1",@"2",@"3",nil];
        NSLog(@"%@",[arr JSONRepresentation]);
    
    logs ["1","2","3"];
  • For JSON to IOS you need to parse the string to convert JSON to an IOS object.
        SBJsonParser *parser=[[SBJsonParser alloc] init];
        NSArray *arr2=[parser
         objectWithString:@"[\"1\",\"2\",\"3\"]"];
        NSLog(@"%@",arr2);
    

And that’s it,you are done with JSON Integration.


Thanks for reading - your comments encourage me, Rama Krishna Chunduri
Share