NSDictionary 结构没有正确完成
NSDictionary structure not getting done properly
我想使用 NSDictionary
创建如下结构
{
"request":
{
"email":"manger@abc.com",
"password":"manager"
}
}
我在 objective C
中使用了以下代码
NSDictionary *paramsDic = [[NSDictionary alloc] initWithObjectsAndKeys:
@"manger@hall.com",@"email",
@"manager",@"password",
nil];
NSDictionary *req = [[NSDictionary alloc] initWithObjectsAndKeys:
paramsDic,@"request",
nil];
但它returns以下响应
{
request =
{
email = "manger@abc.com";
password = manager;
};
}
它显示分号而不是逗号,一个额外的分号和键不是引号
将请求转换为 JSON 对象
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:req options:NSJSONWritingPrettyPrinted error:nil];
NSLog(@"%@", jsonData);
我想使用 NSDictionary
创建如下结构{
"request":
{
"email":"manger@abc.com",
"password":"manager"
}
}
我在 objective C
中使用了以下代码 NSDictionary *paramsDic = [[NSDictionary alloc] initWithObjectsAndKeys:
@"manger@hall.com",@"email",
@"manager",@"password",
nil];
NSDictionary *req = [[NSDictionary alloc] initWithObjectsAndKeys:
paramsDic,@"request",
nil];
但它returns以下响应
{
request =
{
email = "manger@abc.com";
password = manager;
};
}
它显示分号而不是逗号,一个额外的分号和键不是引号
将请求转换为 JSON 对象
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:req options:NSJSONWritingPrettyPrinted error:nil];
NSLog(@"%@", jsonData);