我们正在构建一个iPhone聊天应用程序。为什么Objective-C将JSON值转换为ASCII字符代码的散列?
当从浏览器发送到iPhone一个JSON聊天消息:
{"content":"Hi"}
iPhone的接收:
{"content":{"0":72,"1":105,"length":2}}
但是,我们打算为它收到相同的确切消息。
要重现此问题,请先安装node.js & redis。然后:
获取代码:
git clone git://github.com/acani/acani.git cd acani git submodule update --init
开始Redis的默认端口上。
从http://github.com/acani/acani-node:
node acani-node-server.js # run node.js chat server # open index.html in a Google Chrome or Firefox and follow instructions.
位于http://github.com/acani/acani-chat/tree/master/Lovers2/打开Lovers.xcodeproj,并改变LoversAppDelegate.m最初加载ChatViewController代替HomeViewController的。
homeViewController = [[HomeViewController alloc] init]; # comment out this line # change the next line to: navigationController = [[UINavigationController alloc] initWithRootViewController:[[ChatViewController alloc] init]]; # Then, build & run.
您可以在实际解析JSON的地方显示相关的Objective-C代码吗?您使用的是哪种JSON框架? – 2010-08-26 02:56:10
这不是JSON字符串的转换到NSDictionary中;这样可行。我知道,因为我在这行之后放了一个NSLog:http://github.com/acani/acani-chat/blob/master/Lovers2/ZTWebSocket.m#L207它显示JSON字符串的值的字符有被翻译成ASCII码。 – ma11hew28 2010-08-27 14:20:39