[Code Note] iOS-json File Parsing Methods: ios-json
1. Engineering Drawing.
Ii. Code.
# Import "ViewController. h "# import" SBJson. h "@ interface ViewController () @ end @ implementation ViewController-(void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. // The first JSON parsing method. The built-in JSON parsing method is NSString * datapath = [[NSBundle mainBundle] pathForResource: @ "failureReason" ofType: @ "json"]. NSData * jsonData = [NSData attributes: datapath]; NSMutableDictionary * arrayDic = [NSJSONSerialization JSONObjectWithData: jsonData options: Unknown error: nil]; NSLog (@ "---- arrayDic --- % @", arrayDic); // SBJson parses NSString * filePath = [[NSBundle mainBundle] pathForResource: @ "failureReason" ofType: @ "json"]; NSString * myJSON = [[NSString alloc] initWithContentsOfFile: filePath encoding: NSUTF8StringEncoding error: NULL]; NSDictionary * json = [myJSON JSONValue]; NSLog (@ "-- json -- % @", json );}