【发布时间】:2016-07-03 23:55:12
【问题描述】:
所以我已经坚持了一段时间。我有一个 MongoDB,我查询并以 JSON 形式返回。
我这样做是:
bson.json_utils.dumps(list(all_exams.find(query))
然后我将它传递给一个烧瓶模板变量,以便在 HTML 中的内联 js 脚本中使用。
<div id="results">
<table id="results-table">
</table>
<p>
{{results_json}}
</p>
</div>
<script type="text/javascript" charset="utf-8">
$('#results-table').dynatable({
dataset: {
records: {{results_json}}
}
});
</script>
问题在于,在脚本中,JSON 无法通过 denotable 正确解析,因为它包含 &#34; 这是双引号的实体值,但如果我检查源代码,它不应该看起来像这样。 html 页面不应该将其显示为"。这只发生在脚本部分。不在<p> 标记中(将所有&#34; 打印为")。
我误会了什么?
【问题讨论】:
标签: python html json flask character-encoding