freemarker解析json配列

759 ワード

ここでimgsデータは[{url:'aaa'},{url:'bbbb'}]である.
 
<#assign text>${imgs}</#assign>
	<#assign json=text?eval />
	<#list json as item>
		<img width="30" height="30" src="${item.url}" />
	</#list>

全体コード:
<#macro artimgs imgs>
<div class="mt5 pt10 pl10 pr10 bbd pb5 bgwrite mb5" >
	<#assign text>${imgs}</#assign>
	<#assign json=text?eval />
	<#list json as item>
		<img width="30" height="30" src="${item.url}" />
	</#list>
</div>
</#macro>