手柄栏 - 遍历 JSON 数组
Handle bar - Iterate through JSON array
我正在尝试使用句柄条码遍历 JSON 数组,如下所示。
JSON数组:
[{"email":"zzz@g.com","repo":"https://github.com"},{"email":"xxx@g.com","repo":"https://github.com"},{"email":"yyy@g.com","repo":"https://github.com"}]
处理条码:
{{#each ["abc"].[json]}}
EMAIL:{{["abc"].[json].[@index].[email]}}
REPO:{{["abc"].[json].[@index].[repo]}}
{{#if @last }}
Last entry!
{{/if}}
{{/each}}
其中 ["abc"].[json].[0...100].email/repo 是先前过程的输出 Json 数组。使用上面的代码我没有得到所需的结果并且输出是空字符串,非常感谢任何帮助。
需要输出:
EMAIL:zzz@g.com
REPO:https://github.com
EMAIL:xxx@g.com
REPO:https://github.com
在 #each
帮助器中,上下文切换到当前元素,类似于 JS 中的 forEach 方法:
{{#each ["abc"].[json]}}
EMAIL:{{email}}
REPO:{{repo}}
{{#if @last }}
Last entry!
{{/if}}
{{/each}}
我正在尝试使用句柄条码遍历 JSON 数组,如下所示。
JSON数组:
[{"email":"zzz@g.com","repo":"https://github.com"},{"email":"xxx@g.com","repo":"https://github.com"},{"email":"yyy@g.com","repo":"https://github.com"}]
处理条码:
{{#each ["abc"].[json]}}
EMAIL:{{["abc"].[json].[@index].[email]}}
REPO:{{["abc"].[json].[@index].[repo]}}
{{#if @last }}
Last entry!
{{/if}}
{{/each}}
其中 ["abc"].[json].[0...100].email/repo 是先前过程的输出 Json 数组。使用上面的代码我没有得到所需的结果并且输出是空字符串,非常感谢任何帮助。
需要输出:
EMAIL:zzz@g.com
REPO:https://github.com
EMAIL:xxx@g.com
REPO:https://github.com
在 #each
帮助器中,上下文切换到当前元素,类似于 JS 中的 forEach 方法:
{{#each ["abc"].[json]}}
EMAIL:{{email}}
REPO:{{repo}}
{{#if @last }}
Last entry!
{{/if}}
{{/each}}