Yahoo Pipes、simplejson 和斜杠

发布于 2024-07-14 07:53:27 字数 1531 浏览 6 评论 0原文

我尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恍梦境° 2024-07-21 07:53:27

这里没什么可看的。 票在那儿,但据我所知,仅此而已

Nothing here to see. The ticket is there, but thats it, as far as I can see

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文