Objective c 将数据发布为JSON格式
我正在开发iPhone应用程序。在这里,我尝试使用以下代码发布我的数据:Objective c 将数据发布为JSON格式,objective-c,arrays,cocoa-touch,json,Objective C,Arrays,Cocoa Touch,Json,我正在开发iPhone应用程序。在这里,我尝试使用以下代码发布我的数据: NSDictionary *contactData = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:score] ,@"score", [NSNumber numberWithInt:game_id]
NSDictionary *contactData = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:score] ,@"score",
[NSNumber numberWithInt:game_id] ,@"game_id",
game_version ,@"game_version",
platform ,@"platform",
[NSNumber numberWithInt:timestamp] ,@"timestamp",
[NSNumber numberWithInt:elapsed_time] ,@"elapsed_time",
hash ,@"hash",
[NSNumber numberWithInt:level_reached] ,@"level_reached",
verification ,@"verification",
nil];
[request1 addPostValue:contactData forKey:@"plays[]"];
我想生成以下格式:
Array
(
[plays] => Array
(
[0] => Array
(
[score] = 513956
[game_id] = 1
[game_version] = 1.0
[platform] = Web
[timestamp] = 1313146039
[elapsed_time] = 400
[hash] = 61e51000143566bfddjfhdeur88cb7b2ad
[level_reached] = 5
[verification] = e56a35341c7854dref82ad678cb11593
)
)
[module] => play
[action] => save
)
如何在我必须做出改变或犯错误的地方实施。
请帮帮我。我对此一窍不通。假设您从(?)web服务返回有效的JSON,您可以使用来转换JSON
PHP为此提供了
json\u编码
和json\u解码
。请参阅。这不是JSON,这是PHP的print\r
的输出。请帮助我如何将其转换为有效的JSON?