JSON serialization and deserialization using system API
IOS Version >= 5.0
YHJSONSerialization is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "YHJSONSerialization"
Direct add YHJSONSerialization to your project:
YHJSONSerialization.h
YHJSONSerialization.m
Import header
#import "YHJSONSerialization.h"
NSString *sampleAllString=@"{\"data\":\"abc\",\"info\":\"123\"}";
NSDictionary *object=[sampleAllString objectFromJSON];
NSDictionary *sampleJSONDict=@{ @"opt": @"liek",
@"kind": @[@"a",@"b",[NSNumber numberWithInt:2]],
@"BOOL":[NSNumber numberWithBool:YES]
};
NSString *jsonStr=[sampleJSONDict JSONStringFromDict];
NSArray *sampleJSONArray=@[@"a",@"b",[NSNumber numberWithInt:2]];
NSString *jsonStr=[sampleJSONArray JSONStringFromArray];
Derrick Zhang, derrickzyh@gmail.com
YHJSONSerialization is available under the MIT license. See the LICENSE file for more info.