Original address: http://blog.csdn.net/gf771115/article/details/7718403
//Create JSON
nsdictionary *dictonary = [[Nsmutabledictionary alloc] init];
[Dictonary setvalue:@ "MIle" forkey:@ "name"];
[dictonary setvalue:@ "forkey:@" "Age"];
[dictonary setvalue:@ "male" forkey:@ "sex"];
Nsdictionary *root = [[Nsmutabledictionary alloc] init];
[Root setvalue:dictonary forkey:@ "player"];
Sbjsonwriter *writer = [[Sbjsonwriter alloc] init];
NSLog (@ "Start Create json!");
NSString *value = [writer Stringwithobject:root];
NSLog (value);
//Parse JSON
nsdictionary *dicroot = [[[[Sbjsonparser Alloc]init] objectwithstring:value];
for (int i=0; i< ; [Dicroot Count]; i++) {
Nsdictionary *player = [Dicroot objectforkey:@ "Player"];
NSString *name = [player objectforkey:@ "name"];
NSString *age = [player objectforkey:@ "age"];
NSString *sex = [player objectforkey:@ "sex"];
NSLog (@ "name =%@", name);
NSLog (@ ' age =%@ ', age);
NSLog (@ "sex =%@", sex);
}
IOS uses Sbjson to create and parse JSON