所以目前升循环执行JSON数据从数据库中已经得到了我的控制器:在树枝
public function indexAction()
{
$repository = $this->getDoctrine()->getRepository('ApiBundle:Request');
$themes = $repository->findAll();
return $this->render('ApiBundle:Default:index.html.twig', ['themes' => $themes]);
}
,并在我的树枝:
{% for theme in themes %}
<div am-col="md-6">
<div am-row>
<div am-col="md-3">
{{ theme.preview|json_encode }}
</div>
<div am-col="md-8">
{{ theme.name }}
</div>
</div>
</div>
{% endfor %}
现在theme.previews
如下返回一个JSON:
{"icon_with_video_preview":{"icon_url":"https:\/\/0.s3.envato.com\/files\/170231072\/design-wordpress80.png","landscape_url":"https:\/\/0.s3.envato.com\/files\/170231083\/design-wordpresspreview.jpg","video_url":"https:\/\/0.s3.envato.com\/h264-video-previews\/02e0816d-0957-45c4-af2c-792e37bcc37a\/14727479.mp4"}}
l需要访问并显示icon_url。有任何想法吗? l目前尝试{{ theme.preview.icon_with_video_preview.icon_url }}
,但得到一个错误,说这个数组不能转换为字符串。
您可能想要发布您使用的确切代码,实体/实体的确切错误和相关部分。 – ccKep