Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 使用objective c将json字符串作为httpBody数据发送_Objective C_Json_Ios7 - Fatal编程技术网

Objective c 使用objective c将json字符串作为httpBody数据发送

Objective c 使用objective c将json字符串作为httpBody数据发送,objective-c,json,ios7,Objective C,Json,Ios7,我一直在尝试将转换为nsdata的json字符串发送到http正文部分。 但我总是发现正确的价值观永远不会传递给别人 我在服务器上想要什么: {"request":"{\"Files\":[{'FileName':'11111111','FileType':'test'}]}"} 我在服务器上收到的内容: {"request":{"Files":[{"FileName":"test.html","FileType":"test"}]}} 谁能告诉我我做错了什么: {"request":"{\

我一直在尝试将转换为nsdata的json字符串发送到http正文部分。 但我总是发现正确的价值观永远不会传递给别人

我在服务器上想要什么:

{"request":"{\"Files\":[{'FileName':'11111111','FileType':'test'}]}"}
我在服务器上收到的内容:

{"request":{"Files":[{"FileName":"test.html","FileType":"test"}]}}
谁能告诉我我做错了什么:

{"request":"{\"Files\":[{'FileName':'11111111','FileType':'test'}]}"}
我尝试了以下方法:

{"request":{"Files":[{"FileName":"test.html","FileType":"test"}]}}
方式:1

NSData* jsonData = [NSJSONSerialization dataWithJSONObject:requestDict1 options:0 error:nil];

NSString* jsonString = [[NSString alloc] initWithBytes:[jsonData bytes] length:[jsonData length] encoding:NSUTF8StringEncoding];

[request setHTTPBody:[jsonString dataUsingEncoding:NSUTF8StringEncoding]];
方式:2

NSData* jsonData = [NSJSONSerialization dataWithJSONObject:requestDict1 options:0 error:nil];

[request setHTTPBody:jsonData];
地壳是我想发送nsdata格式的json字符串,但我无法在服务器上获得完美的值。 有人能给我建议一个可能的方法吗?

试试这个

NSData* jsonData = [NSJSONSerialization dataWithJSONObject:requestDict1 options:NSJSONWritingPrettyPrinted error:nil];

NSString* jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

[request setHTTPBody:jsonString];

requestDict1的NSLog是什么?requestDict1::{request={Files=({FileName=“test.html;FileType=test;});};}