問題が発生しました。
次のような JSON の文字列があります。
{"ユーザー名":"ユーザー名","パスワード":"パスワード"}
次のような xcode を使用して、この JSON 文字列を作成します。
NSMutableDictionary *jsonDict = [[NSMutableDictionary alloc] init];
[jsonDict setValue:self.usernameField.text forKey:@"UserName"];
[jsonDict setValue:self.passwordField.text forKey:@"PassWord"];
NSLog(@"Dict: %@",jsonDict);
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:nil];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSLog(@"JSON String: %@",jsonString);
NSString *postStr = [NSString stringWithFormat:@"%@",jsonString];
しかし、今は次のような JSON の文字列が必要です。
{ "comp": [
{ "id": "1" },
{ "id": "2" },
{ "id": "3" }
],
"contact": [
{ "mail": "some@email.com", "name": "Name" },
{ "mail": "email@email.com", "name": "Name" }
]
}
しかし、どうすればこれを行うことができますか? 誰か助けてくれませんか?