擅长:python、mysql、java
<p>我建议使用内置的<a href="https://github.com/facebook/tornado/blob/master/tornado/escape.py" rel="nofollow">json encoder function</a>:</p>
<pre><code>self.write(tornado.escape.json_encode(details)
</code></pre>
<p>如果details是dict类型,tornado将自动对数据进行json编码。对于列表来说,情况并非如此。
从龙卷风密码(网页.py)公司名称:</p>
<blockquote>
<p>Note that lists are not converted to
JSON because of a potential cross-site
security vulnerability. All JSON
output should be wrapped in a
dictionary. More details at
<a href="http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx" rel="nofollow">http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx</a></p>
</blockquote>