JSONObject.toString() 在 2.2 中给出的结果与 2.1 中不同(.Net 日期格式)
在 Android 2.1 中,它
JSONObject o = new JSONObject();
o.put("MyDate", "/Date(1289334937639)/");
Log.d(TAG, o.toString());
会产生
{"MyDate":"/Date(1289334937639)/"}
,但在 2.2 中,它会产生
{"MyDate":"\/Date(1289334937639)\/"}
我正在与 .Net Web 服务交谈,因此 2.2 版本对我来说可以正常工作。如何在不破坏 2.2 的情况下使 2.1 产生相同的结果?
感谢您的帮助。
In Android 2.1 this
JSONObject o = new JSONObject();
o.put("MyDate", "/Date(1289334937639)/");
Log.d(TAG, o.toString());
produces
{"MyDate":"/Date(1289334937639)/"}
but in 2.2 it produces
{"MyDate":"\/Date(1289334937639)\/"}
I am talking to a .Net web service so the 2.2 version works correctly for me. How do I make 2.1 produce the same thing without breaking 2.2?
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从
http://www.json.org/java/
获取最新版本的 JSON 并将其集成到您的代码中。我猜你只需要改变你的进口。Get the latest version of of JSON from
http://www.json.org/java/
and integrate it to your code. You just need to change your imports I guess.我最终得到以下结果:
其中 params 是已经转换为字符串的 json。丑陋,但它有效。
I ended up with the following:
where params is the json already converted to a string. Ugly, but it works.