Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 无法使用velocity模板为每个循环迭代json数组_Arrays_Json_Foreach_Velocity_Velocity Template Language - Fatal编程技术网

Arrays 无法使用velocity模板为每个循环迭代json数组

Arrays 无法使用velocity模板为每个循环迭代json数组,arrays,json,foreach,velocity,velocity-template-language,Arrays,Json,Foreach,Velocity,Velocity Template Language,我有这样一个json: { "name" : "xyz", "age" : "12", "familyprofile" : [{"name" :"abc", "Occupation":"manager","age":"30" },{"name" :"

我有这样一个json:

{
"name" : "xyz",
"age" : "12",
"familyprofile" : 
[{"name" :"abc", "Occupation":"manager","age":"30" },{"name" :"def","Occupation":"housewife","age":"30"}]
}
我正在尝试使用velocity模板在表中打印族配置文件

<table>
<tr>
<td><b>name</b></td>
<td><b>Occupation</b></td>
<td><b>age</b></td>
</tr>
#set($steps = {$headers.familyprofile})
#foreach($step in $steps)
<tr>
<td>step.name</td>
<td>step.Occupation</td>
<td>step.age</td>
</tr>
#end
</table>

名称
职业
年龄
#set($steps={$headers.familyprofile})
#foreach($step in$steps)
步骤名称
步骤.职业
步进年龄
#结束

这是一个语法问题,您应该使用:

#set($steps = $headers.familyprofile)
或:


我使用了${headers.familyprofile}这是一个打字错误。它不起作用。请打印
$headers.familyprofile
$headers.familyprofile.class.name
$headers.familyprofile.size()
,帮助我们了解发生了什么。
#set($steps = ${headers.familyprofile})