【发布时间】:2009-03-04 11:42:25
【问题描述】:
我尝试使用 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"
As far as I can read这是正常的行为:
在 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
【问题讨论】:
-
标准 Django 中的 django.util.simplejson 也没有。
标签: python yahoo-pipes simplejson