使用Twig显示以散列开头的对象属性


Using Twig to show object properties that start with a hash

我正在使用Twig构建一个模板来显示我的最后一个。FM顶级艺人排行榜。最后一部分。fm api返回每个艺术家的图像-当使用json_decode转换为php对象时,它看起来像这样:

object(stdClass)#22 (2) {
    ["#text"]=>
        string(49) "http://userserve-ak.last.fm/serve/34/78224120.png"
    ["size"]=>
        string(5) "small"
}

使用PHP,我可以使用Object->{#text}引用它。我已经尝试了一些方法在树枝- Object.#text, Object[#text]等-但一直得到Unexpected character #

我如何在Twig中引用这个属性?

据我所知:

 $template->render(array('obj', $obj));
 {{ attribute(obj, '#text') }}`