NSJSONSerialization from NSString
问题 Is it possible if I have a NSString and I want to use NSJSONSerialization? How do I do this? 回答1: First you will need to convert your NSString to NSData by doing the following NSData *data = [stringData dataUsingEncoding:NSUTF8StringEncoding]; then simply use the JSONObjectWithData method to convert it to JSON id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; 回答2: You need to convert your NSString to NSData , at that point you can use the +[NSJSONSerialization