我有一个dictionary我需要生成一个JSON string使用dictionary.有可能转换它吗?你能帮忙吗?
如何防止NSJSONSerialization在我的URL字符串中添加额外的反斜杠?
NSDictionary *info = @{@"myURL":@"http://www.example.com/test"};
NSData data = [NSJSONSerialization dataWithJSONObject:info options:0 error:NULL];
NSString *string = [[NSString alloc] initWithData:policyData encoding:NSUTF8StringEncoding];
NSLog(@"%@", string);//{"myURL":"http:\/\/www.example.com\/test"}
Run Code Online (Sandbox Code Playgroud)
我可以去除反斜杠并使用该字符串,但如果可能的话我想跳过这一步......