Yahoo Pipes、simplejson 和斜杠
我尝试使用 http ://www.javarants.com/2008/04/13/using-google-app-engine-to-extend-yahoo-pipes/ 作为灵感,但我在输出方面遇到了一些问题。
在使用控制台和 App Engine“django util simplejson”进行测试时,这一点显而易见:
/cygdrive/c/Program Files/Google/google_appengine/lib/django
$ python
Python 2.5.2 (r252:60911, Dec 2 2008, 09:26:14)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.utils import simplejson as json
>>> json.dumps('/')
'"\\/"'
>>> json.dumps('http://stackoverflow.com')
'"http:\\/\\/stackoverflow.com"
据我所知 这是正常的行为:
在 JSON 中只有反斜杠、双斜杠 引号和 ASCII 控制字符 需要逃脱。 正斜杠 可能会被转义,如 URL 示例中所示 下面,但不是必须的。
但是当输入回 yahoopipes 时,它们不会“转义”输出,并且我所有的 url 和 html 都不起作用。
我真的应该做一个
self.response.out.write(json.dumps(obj).replace('\\/','/'))
吗?
==== 编辑 ===
令我惊讶的是,我发现从 simplejson 网站下载的最新 simplejson 并没有执行“斜线”操作:( 那么真正的问题是应用程序引擎 django.util.simplejson 版本吗?
=== 再次编辑 ===
现在我在跟踪器中为其创建了一个问题:http://code.google.com/p/googleappengine/issues/detail?id=1128
Im trying to use http://www.javarants.com/2008/04/13/using-google-app-engine-to-extend-yahoo-pipes/ as inspiration, but I'm having some troubles with the output.
Its obvious when testing with the console and the App Engine "django util simplejson":
/cygdrive/c/Program Files/Google/google_appengine/lib/django
$ python
Python 2.5.2 (r252:60911, Dec 2 2008, 09:26:14)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.utils import simplejson as json
>>> json.dumps('/')
'"\\/"'
>>> json.dumps('http://stackoverflow.com')
'"http:\\/\\/stackoverflow.com"
As far as I can read this is ok behavior:
In JSON only the backslash, double
quote and ASCII control characters
need to be escaped. Forward slashes
may be escaped as in the URL example
below, but do not have to be.
But when inputting back to yahoopipes, they don't "unescape" the output and all my urls and html doesnt work.
should I really do a
self.response.out.write(json.dumps(obj).replace('\\/','/'))
?
==== Edit ===
To my great suprise I see that newest simplejson downloaded from simplejson site doesnt do the "slash" stuff :(
So the real issue is with app engines django.util.simplejson version?
=== Edit again ===
And now Ive created an issue in the tracker for it: http://code.google.com/p/googleappengine/issues/detail?id=1128
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里没什么可看的。 票在那儿,但据我所知,仅此而已
Nothing here to see. The ticket is there, but thats it, as far as I can see