英文:
How to render json data with @ character in its key using handlebars?
问题
这是我的 JSON 数据:
var data = {john@gmail.com: true}
在我的模板中,我尝试以下方式来显示数据,但不起作用:
{{data.[john@gmail.com]}}
我甚至尝试了这种方式:
{{data.['john@gmail.com']}}
还有这种方式:
{{data.john@gmail.com}}
但是,如果我将我的 JSON 数据更改为:
var data = {john:true}
并尝试:
{{data.[john]}}
它就能正常工作,并显示输出为 true。
请问有人可以指出我在哪里出错了吗?
英文:
This is my json data
var data = {john@gmail.com: true}
In my template i am trying this way to display data but its not working
{{data.[john@gmail.com]}}
I even tried this way
{{data.['john@gmail.com']}}
and also
{{data.john@gmail.com}}
but if i had changed my json data to
var data = {john:true}
and try
{{data.[john]}}
its working and displaying the output as true
Can anyone please point me where i am making mistake ?
答案1
得分: 1
这是 data["john@gmail.com"]
。这里 有一个很好的资源可供阅读。
英文:
It is like this data["john@gmail.com"]
. Here is a good Resource to read
专注分享java语言的经验与见解,让所有开发者获益!
评论