iOS 的 JSON 反序列化
我正在尝试为我正在编写的 iOS 应用程序反序列化 JSON 字符串。但是,我的应用程序始终挂在我尝试读取的提要中双引号的“\”转义序列上。有什么快速方法可以删除该序列以便我可以正确解析提要? (提要来自服务器端的 Django 应用程序。)
这是我的 json 字符串:
[{\"pk\": 4161, \"model\": \"news.article\", \"fields\": {\"date_live\": \"2011-11-03 00:00:01\", \"date_added\": \"2011-11-03 03:10:59\", \"date_modified\": \"2011-11-03 03:10:59\", \"slug\": \"thursday-feature-backup-comic\", \"title\": \"THURSDAY FEATURE --> Backup Comic\"}}
您会注意到我的所有“节点”都有用于引用的“\”转义序列。有什么想法吗?
在此先感谢您提供的任何帮助。
L。
I am trying to deserialize a JSON string for an iOS app that I am writing. However, my app keeps getting hung up on the "\" escape sequence for double-quotes in the feed I am trying to read. What is a quick way to strip out that sequence so I can parse the feed correctly? (The feed is coming from my Django application on the server-side.)
Here is my json string:
[{\"pk\": 4161, \"model\": \"news.article\", \"fields\": {\"date_live\": \"2011-11-03 00:00:01\", \"date_added\": \"2011-11-03 03:10:59\", \"date_modified\": \"2011-11-03 03:10:59\", \"slug\": \"thursday-feature-backup-comic\", \"title\": \"THURSDAY FEATURE --> Backup Comic\"}}
You will notice that all of my "nodes" have the "\" escape sequence for the quote. Any ideas?
Thank you in advance for any help here.
L.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您尝试删除 python 中的转义符:
但如果您想删除 javascript 中的转义符:
注意: 您忘记了字符串末尾的 ] 。至少当我尝试评估它时我遇到了错误。我把 ] 放在最后并且 eval 工作了。
If you are trying to remove the escape inside python:
But if you want to remove the escape from javascript:
Note: You forgot a ] at the end of your string. At least I had an error when I've tryed to eval it. I put the ] at the end and eval worked.