[英]Error: missing : after property id?
I'm trying to solve the problem in JSON, for some reason I'm getting the error in this line of code: 我正在尝试解决JSON中的问题,由于某种原因,我在以下代码行中遇到了错误:
SyntaxError: missing : after property id
jsObj[area-yearId [key]] = {100, 2500};
My original code looks like this: 我的原始代码如下所示:
var jsObj = {};
<cfoutput query="myQuery">
jsObj[building-term [key]] = {#myQuery.area#, #myQuery.yearId#};
jsObj[building-term key].startdate = #myQuery.sDate#;
jsObj[building-term key].enddate = #myQuery.eDate#;
</cfoutput>
alert(JSON.stringify(jsObj));
If anyone can help please let me know. 如果有人可以帮忙,请告诉我。
Either you declare it as an array or you add ids: 您可以将其声明为数组或添加ID:
[100, 2500];
{id1: 100, id2: 2500};
The {} in jsObj[area-yearId [key]] = {100, 2500};
jsObj[area-yearId [key]] = {100, 2500};
is interpreted as object literal, not a code block (terminology?). 被解释为对象文字,而不是代码块(术语?)。 Object literals are in the form
{ id: property }
, hence the error message. 对象文字的格式为
{ id: property }
,因此会出现错误消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.