For details about NSJSONSerialization, the official documents include: You use the NSJSONSerialization class to convert JSON to Foundation objects and convert Foundation objects to JSON. an object that may be converted to JSON must have the following properties: The top level object is an NSArray or NSDictionary. all objects are instances of NSString, NSNumber, NSArray, NSDictionary, or NSNull. all dictionary keys are instances of NSStri Ng. numbers are not NaN or infinity. you can use NSJSONSerialization to convert JSON to a Foundation object or a Foundation object to JSON. the object to be converted to JSON must have the following attributes: the top-level object must be NSArray or NSDictionary. All objects must be NSString, NSNumber, NSArray, NSDictionary, and NSNull. The keys of all NSDictionary instances must be NSString numeric objects and cannot be non-numeric or infinite. Next let's look. how to use, first, how to generate data in JSON format: Here I will use code snippets in the project for a brief introduction, [cpp] NSDictionary * registerDic = [NSDictionary dictionaryWithObjectsAndKeys: uuid, @ "_ Id", userName, @ "login_name", password, @ "password", nil]; if ([NSJSONSerialization isValidJSONObject: registerDic]) {NSError * error; NSData * registerData = [NSJSONSerialization dataWithJSONObject: registerDic options: Unknown error: & error]; NSLog (@ "Register JSON: % @", [[NSString alloc] initWithData: registerData encoding: NSUTF8StringEncoding]);} the key in NSDictionary is the key in the json string, obje Ct is the value in the json string. isValidJSONObject: The method is to check whether the Foundation object can be legally converted to a JSON object, and the dataWithJSONObject: options: error method is to convert the Foundation object to a JSON object, the NSJSONWritingPrettyPrinted parameter is used to format the output of the generated json data, which is highly readable. If this parameter is not set, the output json string is a whole line. Parse json format data returned by the server: [cpp] NSDictionary * resultJSON = [NSJSONSerialization JSONObjectWithData: resultData options: kNilOptions error: & error]; obtain the value of the returned string whose key is status: [cpp] NSString * status = [resultJSON objectForKey: @ "status"]; The above briefly introduces the use of NSJSONSerilazation, which is not very comprehensive. I will explain it in detail later.