JSON配列形式でデータをPOSTする必要のあるiPhoneアプリケーションで作業していますが、試して送信しましたが、バックエンドでJSON配列として取得できません。私は私の配列を作成して送信するため、次のコードを使用:JSON配列形式
NSMutableArray *playsArr=[[NSMutableArray alloc]init];
int score=[[NSNumber numberWithInt:100 ]intValue];
int game_id=[[NSNumber numberWithInt:1 ]intValue];
NSString *[email protected]"1.1";
// Time stamp in Unix format
int timestamp=[[NSNumber numberWithInt:1312582440]intValue];
int elapsed_time=[[NSNumber numberWithInt:500]intValue];
int level_reached=[[NSNumber numberWithInt:1 ]intValue];
NSString *[email protected]"ios";
NSString *[email protected]"801356a3b23c8e2ed94455545ddere";
NSString *[email protected]"676c66df9b529895a97cd5f4d55ef";
NSLog(@"%@",verification);
NSMutableDictionary *dict=[[NSMutableDictionary alloc]init];
[dict setObject:[NSNumber numberWithInt:score] forKey:@"score"];
[dict setObject:[NSNumber numberWithInt:game_id] forKey:@"game_id"];
[dict setObject:game_version forKey:@"game_version"];
[dict setObject:platform forKey:@"platform"];
[dict setObject:[NSNumber numberWithInt:timestamp] forKey:@"timestamp"];
[dict setObject:[NSNumber numberWithInt:elapsed_time] forKey:@"elapsed_time"];
[dict setObject:hash forKey:@"hash"];
[dict setObject:[NSNumber numberWithInt:level_reached] forKey:@"level_reached"];
[dict setObject:verification forKey:@"verification"];
NSLog(@"%@",dict);
[playsArr addObject:dict];
[request addPostValue:playsArr forKey:@"plays"];
[request setTimeOutSeconds:600];
[request setDelegate:self];
[request setDidFailSelector:@selector(uploadFailed:)];
[request setDidFinishSelector:@selector(uploadFinished:)];
[request startAsynchronous];
今私は、バックエンドから取得していますコメントは、彼らは、アレイとその返すエラーまたはnull応答としてで取得されていませんされています。
ここで私はJSON配列形式を間違えていますか? コード行を手伝ってください......
ありがとうございます。
私はこのような構造をしなければならない......
アレイ( [演劇] =>配列 ( [0] => [スコア] = 513956 [1] => [ [4] => [タイムスタンプ] = 1313146039 [5] => [elapsed_time] = 400 [1] 6] => [hash] = 61e51000143566bfd2e3aefa7cb7b2ad [7] => [level_reached] = 5 [8] => [verification] = e56a35341c8dd44fa082ad678cb11593 ) [モジュール] => [アクション] => を保存をプレイ)
...
[JSONへの配列のフォーマット]の可能な複製(http://stackoverflow.com/questions/7066543/formatting-an-array-into-json) –