(IOS) JSON 파싱 라이브러리 JOSINKit 사용하기
안녕하세요.
이제 막 아이폰 개발 공부를 시작했습니다.
블로그에도 관련 포스팅이 많이 늘어날것같네요.!
오늘 그 시작으로 JSOINKit 라이브러리를 정리해놓습니다.
기본 JSON파싱보다 약 3배 빠르다고하네요!
https://github.com/johnezang/JSONKit
에서 다운가능합니다.
.h, .m 2개의 파일로 구성되어있습니다 (정말 간단하죠!)
사용법
#import "JSONKit.h"
...
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"items" ofType:@"json"];
NSString *a = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
// 클래스의 종류 및 내용보기
// NSLog(@"class:%@ a:%@",[a class], a);
// JSON을 NSArray나 NSDictionary 로 변환
NSArray *array = [a objectFromJSONString];
NSLog(@"class: %@, %d", [array class], [array count]);
// Array에서 Dictionary 가져오기
NSDictionary *dic = [array objectAtIndex:0];
NSLog(@"dic name:%@", [[dic valueForKey:@"name"] description]);
빌드하면 ARC 에러가 나면?
http://j2enty.tistory.com/107 arc에러 대처