我试图在javascript变量中获取json.我在我的extbase typo3-extension中使用了fluid-templates.在我的动作中,我加载了一些卷曲的json.这个json我分配给模板.在我的模板中,它看起来像:
<script type="text/javascript">
var json = {jsonVarFromControllerAction};
</script>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,json被解释为html代码.看起来像:
{"content":"testcontent"}
Run Code Online (Sandbox Code Playgroud)
在控制器动作中它是一个正确的json!
{"content": "testcontent"}
Run Code Online (Sandbox Code Playgroud)
什么是解决方案?