0
表單API我有JSON數據,如下所示。我是node.js中的新成員,所以我不知道如何解析JSON數據。Json數據在node.js句柄中解析
[
{
"Detail": " Rs. 1001 Full Talktime Topup Rs.1001 Full Talktime",
"Amount": "1001",
"Validity": "Unlimited"
},
{
"Detail": " Rs. 1000 Full Talktime Topup Rs.1050 more than Full Talktime",
"Amount": "1000",
"Validity": "Unlimited"
},
{
"Detail": " Rs. 899 Full Talktime Topup Rs.899 Full Talktime",
"Amount": "899",
"Validity": "Unlimited"
},
{
"Detail": " Rs. 501 Full Talktime Topup Rs.501 Full Talktime",
"Amount": "501",
"Validity": "Unlimited"
},
{
"Detail": " Rs. 500 Full Talktime Topup Rs.500 Full Talktime",
"Amount": "500",
"Validity": "Unlimited"
},
{
"Detail": " Rs. 225 Full Talktime Topup Rs.225 Full Talktime",
"Amount": "225",
"Validity": "30 days"
},
{
"Detail": " Rs. 59 Full Talktime Topup Rs.59 Full Talktime",
"Amount": "59",
"Validity": "7 days"
},
{
"Detail": " Rs. 32 Full Talktime Topup Rs.32 Full Talktime",
"Amount": "32",
"Validity": "3 days"
}
]
handlebars.registerHelper是
hbs.registerHelper("FTT", function(author){
return JSON.stringify(code);
});
和把手模板
{{#each FTT}}
<tr>
<td>Hello</td>
<td>{{FTT.[0].Detail}}</td>
<td>{{this.[0].Amount}}</td>
<td>{{Validity}}</td>
</tr>
{{/each}}
在FTT不displaing什麼。我也嘗試不同的sugeestion,但仍然沒有獲得任何地方。 任何sugession,
使用'JSON.parse(代碼)','JSON.stringify(代碼)'把它轉換成一個字符串。 –
我也試過,但每個都不是循環投擲FTT你可以建議任何活的例子 –