访问javascript数组中带有特殊字符的格式化值(access formatted value with special character in javascript array)

我得到一个对象作为api调用的响应

该对象如下所示

现在,当我尝试response._modifiedby_value我得到正确的响应,但是当我尝试response.createdby_value@OData.Community.Display.V1.FormattedValue我收到以下错误

Uncaught SyntaxError {message: "Unexpected token ILLEGAL"}

I am getting an object as response for an api call

The object looks like below

Now when I try response._modifiedby_value I am getting the right response, but when I try response.createdby_value@OData.Community.Display.V1.FormattedValue I am getting the below error

Uncaught SyntaxError {message: "Unexpected token ILLEGAL"}

最满意答案

那是因为'@'是一个特殊的角色,所以你做不到:

response.createdby_value@OData = 2;

但反而

response["createdby_value@OData"] = 2;

that's because '@' is a special character, therefore you can't do:

response.createdby_value@OData = 2;

but instead

response["createdby_value@OData"] = 2;访问javascript数组中带有特殊字符的格式化值(access formatted value with special character in javascript array)

我得到一个对象作为api调用的响应

该对象如下所示

现在,当我尝试response._modifiedby_value我得到正确的响应,但是当我尝试response.createdby_value@OData.Community.Display.V1.FormattedValue我收到以下错误

Uncaught SyntaxError {message: "Unexpected token ILLEGAL"}

I am getting an object as response for an api call

The object looks like below

Now when I try response._modifiedby_value I am getting the right response, but when I try response.createdby_value@OData.Community.Display.V1.FormattedValue I am getting the below error

Uncaught SyntaxError {message: "Unexpected token ILLEGAL"}

最满意答案

那是因为'@'是一个特殊的角色,所以你做不到:

response.createdby_value@OData = 2;

但反而

response["createdby_value@OData"] = 2;

that's because '@' is a special character, therefore you can't do:

response.createdby_value@OData = 2;

but instead

response["createdby_value@OData"] = 2;