把手不会渲染json

时间:2016-09-23 09:48:10

标签: handlebars.js handlebars.java

JSON它来自:

unverifiedCompanies=[{"email":"testcompany@company.com","company_number":"09999999","company_name":"Name_123","full_name":"test","phone_number":"xyz"},{"email":"testtwo@company.com","company_number":"09999999","company_name":"Name_123","full_name":"test","phone_number":"xyz"}]

使用

进行迭代
{{#each unverifiedCompanies}}
<tr>
  <td>{{this}}</td>
  <td>{{this.company_name}}</td>
  <td>{{this.full_name}}</td>
  <td>{{phone_number}}</td>
  <td>{{email}}</td>
</tr>
{{/each}}

但是,只有{{this}}显示{"email":"testcompany@company.com","company_number":"09999999","company_name":"Name_123","full_name":"test","phone_number":"xyz"}{"email":"testtwo@company.com","company_number":"09999999","company_name":"Name_123","full_name":"test","phone_number":"xyz"},所有其他人都不会显示。

我错过了什么吗?

1 个答案:

答案 0 :(得分:0)

使用大括号{}包装您的内容,以使其具有JSON格式。我猜你遇到的问题是未经证实的公司没有得到解决。

{unverifiedCompanies=[{"email":"testcompany@company.com","company_number":"09999999","company_name":"Name_123","full_name":"test","phone_number":"xyz"},{"email":"testtwo@company.com","company_number":"09999999","company_name":"Name_123","full_name":"test","phone_number":"xyz"}]}