Apple provides json-related processing APIs for ios5, the most important of which is the NSJSONSerialization class.
+ (BOOL)isValidJSONObject:( + (NSData *)dataWithJSONObject:()obj options:(NSJSONWritingOptions)opt error:(NSError ** + ()JSONObjectWithData:(NSData *)data options:(NSJSONReadingOptions)opt error:(NSError **)error;
The most common method is the above three class methods.
The first one is used to determine whether the current data can be converted to JSON,
The second is to convert the data into JSON and return NSData,
The third is to parse JSON.
Example:
NSMutableDictionary *dictionary = [dictionary setValue: forKey: [dictionary setValue: forKey: NSArray *otherValueArray = @[, , , [dictionary setValue:otherValueArray forKey: NSError *error = NSData *jsonData = error:& NSLog( NSString *jsonString = resultString = error:& NSLog( NSArray *navigatorArray = resultString[ NSLog( jsonString, resultString, navigatorArray);
NSLog output result:
By the way,Can be used.
According to tests by netizens, this built-in resolution efficiency is faster than several third-party JSON libraries on the Internet.