JSON - Access字段命名为'*'星号星号、字段、命名为、JSON

2023-09-10 14:13:36 作者:晚雾

我试图访​​问一个字段的JSON对象在JavaScript中有关键'*'。 该jsonstring看起来是这样的:

  {解析:
 {文本:
  {*:文字我想访问}
 }
}
 

试图访问myObject.parse.text。*不工作,也不做myObject.parse.text [0]。 我已经寻找了一个小时了,但还没有发现任何暗示星号具有特殊的意义。 如果我只是遍历整个树,使字符串比较一拉如果(关键==*)我能得到我想要检索的文本,但我想直接进入这一领域。 请问有没有办法进入现场?

解决方案

  json.parse.text [*]
 

有关对象成员令人讨厌的名字。

JsonToAccess Json转Access工具 软件下载 JsonToAccess Json转Access工具 下载安装地址v2.0官方版

I am trying to access a field in a json object in javascript which has the key '*'. The jsonstring looks like this:

{"parse":
 {"text":
  {"*":"text i want to access"}
 }
}

Trying to access myObject.parse.text.* does not work, neither does myObject.parse.text[0]. I have searched for an hour now, but havent found any hint that the asterisk has a special meaning. If I just traverse the complete tree and make String comparison a la 'if (key == "*")' I can get the text I want to retrieve, but I would like to directly access this field. Is there no way to access the field ?

解决方案

json.parse.text["*"]

Yucky name for an object member.