1

我有一些看起来像这样的json:

{{...},
"skills": [{
        "languages": ["Java", "JavaScript", "C", "HTML5", "CSS3", "PHP", "Python"],
        "j2ee": ["JSP", "Struts", "Tiles"],
        "servers": ["Apache Tomcat 5, 6", "Webshpere Application Server", "Node.js", "Django (Python framework)"],
        "tools": ["Eclipse and Rational Application Developer", "Maven", "vim", "*nix CLI"],
        "versions": ["Git", "MKS", "Accurev", "SubVersion", "CVS"]
}], 
{...}}

部分车把看起来像这样:

{{#each skills}}
<div id="{{this}}">
<ul>
    {{#list this}}
    <li>{{this}}</li>
    {{/list}}
</ul>
</div>
{{/each}}

这显然是行不通的,但我的想法是我可以以skills编程方式迭代数组,这样我就不必将键放入,然后迭代每个键的值(一个数组)。

我知道我可以做类似的事情

{"skills": 
    [{"name": "languages", 
      "values":["Java",...]},
     {"name": "j2ee", 
      "values":["JSP",...]},
     {...}]}

但我想知道是否有办法用第一个结构来做到这一点。

4

0 回答 0