iOS 网络上获取的json格式转换成NSString格式

- (NSString*)DicToString:(NSDictionary*)dic {

NSError*error;

NSData*policyData =                 [NSJSONSerializationdataWithJSONObject:dicoptions:kNilOptionserror:&error];

         if(!policyData && error)

         {

                  NSLog(@"Error creating JSON: %@", [errorlocalizedDescription]);

                  returnnil;

        }

         NSString* policyStr = [[NSStringalloc]initWithData:policyDataencoding:NSUTF8StringEncoding];

         policyStr = [policyStrstringByReplacingOccurrencesOfString:@"\\/"withString:@"/"];

         policyData = [policyStrdataUsingEncoding:NSUTF8StringEncoding];

         returnpolicyStr;

}

你可能感兴趣的:(iOS 网络上获取的json格式转换成NSString格式)